Div不加载jQuery [英] Div doesnt load with jquery
问题描述
< div id =email_response < div id =email_loader>
< img src =/ img / ajax_load.gif.pagespeed.ce.sBYFmTTK7I.gif>
< / div>
jQuery :
$(#email_loader)。html(< img src ='http://example.com/ img / ajax_load.gif'/>);
$(#email_response)。fadeIn(500);
$ .get(http://example.com/inc_appdl_main_api.php,{
to:to,
app_id:FA.appID
},函数(数据) {
if(data.length> 0){
$(#email_loader)。html(data);
$(#email_response)。delay(1000).fadeOut (500);
}
});
setTimeout(FA.iframeClose(),2000);
div email_response应该加载/淡入半秒钟。然后应该从jquery ..然后结束一个包含所有html标记的iframe应该关闭..
除了获取成功函数中的代码外, $ b我知道成功函数实际上是触发的......因为服务器(php)的代码,做它做什么!!!
什么问题?
成功函数中的代码不起作用:($ / b>
if(data .length> 0){
$(#email_loader)。html(data);
$(#email_response)。delay(1000).fadeOut(500);
}
更新:
这是我在控制台中获得的内容。 TRIGGERED。
XMLHttpRequest无法加载http://example.com/inc_appdl_main_api.php?to=makovetskiyd%40yahoo.co.uk& ; app_id = 81。原始http://api.example.com不被Access-Control-Allow-Origin允许。
html标记和javascript在iframe中有另一个站点。
Access- Control-Allow-Origin。您正在访问您的域外的某些内容吗? cross -domain-请求与 - jQuery的 , cross-domain-ajax-querying- with-jquery
I have a problem with div loading/fading.. This is my html.
<div id="email_response">
<div id="email_loader">
<img src="/img/ajax_load.gif.pagespeed.ce.sBYFmTTK7I.gif">
</div>
The jQuery:
$("#email_loader").html("<img src='http://example.com/img/ajax_load.gif' />");
$("#email_response").fadeIn(500);
$.get("http://example.com/inc_appdl_main_api.php", {
to : to,
app_id : FA.appID
}, function(data) {
if (data.length > 0) {
$("#email_loader").html(data);
$("#email_response").delay(1000).fadeOut(500);
}
});
setTimeout ( "FA.iframeClose()", 2000 );
The div email_response , should load/fadeIn for half a second..then the response should be obtained from jquery ..and then a the end an iframe that contains all the html markup should close..
Everything works apart from the code inside the get success function.. I know that the success function is actually triggered..cause the server (php) code, does what it does!!!
Whats the problem? I dont see the response fading out.. The code inside the success function doesnt work :(
if (data.length > 0) {
$("#email_loader").html(data);
$("#email_response").delay(1000).fadeOut(500);
}
UPDATE: THIS IS WHAT I GET IN THE CONSOLE. AFTER THE GET FUNCTION IS TRIGGERED.
XMLHttpRequest cannot load http://example.com/inc_appdl_main_api.php?to=makovetskiyd%40yahoo.co.uk&app_id=81. Origin http://api.example.com is not allowed by Access-Control-Allow-Origin.
The html markup and javascript is in an iframe which has another site on it..
Access-Control-Allow-Origin. You are accessing something out of your domain? cross-domain-requests-with-jquery, cross-domain-ajax-querying-with-jquery
这篇关于Div不加载jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!