Jsf ajax not found in javascript file (jsf.ajax)

huangapple go评论60阅读模式
英文:

Jsf ajax not found in javascript file (jsf.ajax)

问题

Hello, it seems you are encountering an issue with your JavaScript code when using JSF. The error message "Uncaught ReferenceError: jsf is not defined" suggests that the 'jsf' object or variable is not recognized in your script.

This might be due to changes or differences in JSF versions or configurations. You may want to check your JSF setup and make sure that the 'jsf' object is accessible in your environment. Additionally, ensure that you have included the necessary JSF libraries or dependencies in your project.

If you have further questions or need assistance with resolving this issue, please feel free to ask.

英文:

Hello : I see that answer an I think I can use it in my code :Show loading progress when making JSF Ajax request
But when I use this method in javascript code :

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

jsf.ajax.addOnEvent(function (data) {
    var ajaxstatus = data.status; // Can be &quot;begin&quot;, &quot;complete&quot; and &quot;success&quot;
    var ajaxloader = document.getElementById(&quot;ajaxloader&quot;);

    switch (ajaxstatus) {
        case &quot;begin&quot;:
            console.log(&quot;Begin&quot;);
            break;

        case &quot;complete&quot;:
            console.log(&quot;Completed&quot;);
            break;

        case &quot;success&quot;:
            console.log(&quot;Suc&quot;);
            break;
    }
});

<!-- end snippet -->

the console show me :

DpsMain.js:58 Uncaught ReferenceError: jsf is not defined
    at DpsMain.js:58:1

Is that changed in JSF ?
or I missing something?
Versions :
GlassFish 7.0.3 Jakarta EE 10
JDK 17

The goal of my code is show loading entire the components and User View in safe way and easiest way! for minimum change in my codes or something else.

答案1

得分: 0

Ops , 我找到了!
在雅加达改名为 faces
所以我需要把 Jsf 改成 faces ,如下
faces.ajax.addOnEvent(function (data) {
var ajaxstatus = data.status; // 可以是 "begin", "complete" 和 "success"
var ajaxloader = document.getElementById("ajaxloader");

switch (ajaxstatus) {
    case "begin":
        console.log("开始");
        break;

    case "complete":
        console.log("完成");
        break;

    case "success":
        console.log("成功");
        break;
}

});


现在它可以工作了!
如果问了一个愚蠢的问题,对不起。
英文:

Ops , I founded!
In jakarta changed name into faces
so I need to change Jsf into faces , Like blow

    faces.ajax.addOnEvent(function (data) {
    var ajaxstatus = data.status; // Can be &quot;begin&quot;, &quot;complete&quot; and &quot;success&quot;
    var ajaxloader = document.getElementById(&quot;ajaxloader&quot;);

    switch (ajaxstatus) {
        case &quot;begin&quot;:
            console.log(&quot;Begin&quot;);
            break;

        case &quot;complete&quot;:
            console.log(&quot;Completed&quot;);
            break;

        case &quot;success&quot;:
            console.log(&quot;Suc&quot;);
            break;
    }
});

now its work!
Sorry if asked a stupid question.

huangapple
  • 本文由 发表于 2023年5月14日 11:06:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/76245644.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定