Closed horsemanjackyliu closed 1 year ago
Hi @horsemanjackyliu,
I just tested it myself and this works:
MainView.controller.js
sap.ui.define(
["./BaseController"],
/**
* @param {typeof sap.ui.core.mvc.Controller} Controller
*/
function (Controller) {
"use strict";
return Controller.extend("com.myorg.myUI5App.controller.MainView", {
onInit: function () {
console.log(jQuery.ajax())
console.log(new XMLHttpRequest())
},
});
}
);
Can you try jQuery.ajax()
?
Best, Nico
Hey Nico,
hope you don't mind if I add a cross reference to the SAP Community question: https://blogs.sap.com/2021/04/09/easy-ui5-3.0-from-community-contributions-to-community-plugins/comment-page-1/#comment-650545
Some comments:
The way you access jQuery here is by using the global namespace (tbh. kind of like with the XHR anyway :D) but if you really want to use jQuery within UI5 atm. shouldn't you also import it within sap.ui.define
(using sap/ui/thirdparty/jquery
) rather than just accessing the global?
Regarding the XMLHttpRequest error, I think this relates to missing TS types maybe?
BR, Marco :)
Hi @wridgeu, Thanks, appreciate it! Makes total sense to skip the whole global thing - thanks for pointing it out.
@horsemanjackyliu, do you experience runtime errors as well? Or is this only regarding type checking during development?
Best, Nico
Easy-Ui5 version:
Node.js: v14.19.3 yeoman-environment: 3.9.1 generator-easy-ui5: 3.3.0 home: C:\Develop\nodejs\node_global\node_modules\generator-easy-ui5 pluginsHome: C:\Develop\nodejs\node_global\node_modules\generator-easy-ui5\plugin-generators
Available generators:
OS/version: win 10 21H2
Browser/version (+device/version): Microsoft Edge 107.0.1418.62 (Official build) (64-bit)
Steps to reproduce the problem:
the error is "Cannot find name 'XMLHttpRequest'.ts(2304)"
$.ajax also can not be used .
What is the expected result?
In the generated project XHR and ajax can be used .
What happens instead?
Any other information? (attach screenshot if possible)