In my code, I have:
在我的代码中,我有:
$(document).ready(function() {
$.ajaxSetup ({
// Disable caching of AJAX responses */
cache: false
});
//pop_i = setInterval( "load_result()", 1000 );
load_result();
load_f();
});
but it doesn't always load. I know this because load_f()
has an alert which doesn't get triggered sometimes.
但它并不总是装载。我知道这一点,因为load_f()有一个警告,有时不会被触发。
3 个解决方案
#1
1
If you are sure your JavaScript looks right and you're not getting any errors in Firebug, chances are it's the JSON being sent back from the server that's tripping things up.
如果您确信您的JavaScript看起来是正确的,并且在Firebug中没有出现任何错误,那么很可能是服务器返回的JSON导致了问题。
Where load_f
fails to run copy-paste the result of your GET/POST requests from Firebug into your text-editor and pour through them with a fine-tooth comb to make sure the JSON is well-formed.
当load_f无法将来自Firebug的GET/POST请求的结果复制粘贴到文本编辑器中,并对其进行细致的梳理,以确保JSON格式良好。
#2
2
Don't know if this applies to your situation.
不知道这是否适用于你的情况。
I've just come across an issue whereby $(document).ready() event wasn't being fired. As it turns out, the jQuery $(document).ready() event is not fired in async postbacks when used w/ ASP.net UpdatePanels. One solution is to refactor the $(document).ready() logic into an explicit function () so that it can also be registered w/ the ASP.net Sys.WebForms.PageRequestManager endRequest event (fired on every async postback). Details can be found on the question I posted earlier today...
我刚刚遇到一个问题,$(document).ready()事件没有被触发。事实证明,当使用w/ ASP.net UpdatePanels时,jQuery $(document).ready()事件不会在异步回发中触发。一种解决方案是将$(document).ready()逻辑重构为显式函数(),以便也可以注册w/ ASP.net Sys.WebForms。PageRequestManager endRequest事件(针对每个异步回发)。细节可以在我今天早些时候发布的问题上找到……
#3
1
What happens in load_result
and load_f
? Since the ready
function attaches a listener, if an error occurs you will sometimes not see it.
load_result和load_f中发生了什么?由于ready函数附加一个侦听器,因此如果出现错误,有时您将看不到它。
#1
1
If you are sure your JavaScript looks right and you're not getting any errors in Firebug, chances are it's the JSON being sent back from the server that's tripping things up.
如果您确信您的JavaScript看起来是正确的,并且在Firebug中没有出现任何错误,那么很可能是服务器返回的JSON导致了问题。
Where load_f
fails to run copy-paste the result of your GET/POST requests from Firebug into your text-editor and pour through them with a fine-tooth comb to make sure the JSON is well-formed.
当load_f无法将来自Firebug的GET/POST请求的结果复制粘贴到文本编辑器中,并对其进行细致的梳理,以确保JSON格式良好。
#2
2
Don't know if this applies to your situation.
不知道这是否适用于你的情况。
I've just come across an issue whereby $(document).ready() event wasn't being fired. As it turns out, the jQuery $(document).ready() event is not fired in async postbacks when used w/ ASP.net UpdatePanels. One solution is to refactor the $(document).ready() logic into an explicit function () so that it can also be registered w/ the ASP.net Sys.WebForms.PageRequestManager endRequest event (fired on every async postback). Details can be found on the question I posted earlier today...
我刚刚遇到一个问题,$(document).ready()事件没有被触发。事实证明,当使用w/ ASP.net UpdatePanels时,jQuery $(document).ready()事件不会在异步回发中触发。一种解决方案是将$(document).ready()逻辑重构为显式函数(),以便也可以注册w/ ASP.net Sys.WebForms。PageRequestManager endRequest事件(针对每个异步回发)。细节可以在我今天早些时候发布的问题上找到……
#3
1
What happens in load_result
and load_f
? Since the ready
function attaches a listener, if an error occurs you will sometimes not see it.
load_result和load_f中发生了什么?由于ready函数附加一个侦听器,因此如果出现错误,有时您将看不到它。