Ody*_*dys 6 php jquery jquery-load
我正在使用一个简单的ajax加载器来获取wordpress上的内容.
$("#page_preview").load("ajaxloader/", function(response, status, xhr) {
if (status == "error") {
alert("Sorry but there was an error");
}
else
{
$('#page_preview').fadeIn(300);
}
});
return;
Run Code Online (Sandbox Code Playgroud)
当我加载一个嵌入了谷歌地图的特定帖子时,显然出现了问题,但不是进入if语句,萤火虫表明它超出了这段代码.无论是if或else打击.
使用eclipse调试器我发现页面加载成功,但是当它将数据返回给.load()方法时,最后一次中断.
关于可能发生的事情的任何想法?
<script>
// as of jQuery 1.5.x ++
var pagePreview = $("#page_preview");
$.get("ajaxloader/").success(
function(response, status, jqXhr) {
alert("Success!");
pagePreview.empty();
pagePreview.append(response);
// i feel you need to parse the response for the google map div, and perform another $.get() of the google url?
}).error(function(response, status, jqXhr) {
alert("These are not the droids you are looking for. move along.");
}).complete(function(response, status, jqXhr) {
alert("Complete!");
});
</script>
Run Code Online (Sandbox Code Playgroud)
jQuery.load()将为您提供文档。.load 相当于这个
它大致相当于 $.get(url, data, success ) ,只不过它是一个方法而不是全局函数,并且它有一个隐式回调函数。当检测到成功响应时(即当textStatus为“成功”或“未修改”时),.load()将匹配元素的HTML内容设置为返回的数据。
您需要注册$.ajax( complete:function(responseText, textStatus, XMLHttpRequest)){}); 并检查该textStatus值。如果可以,则自行将数据加载到目的地$('selector')。或者.load()通过在 chrome 中观察您的网络 xmlHttpRequests (ctrl + shift +j) 或 firebug 中的某些网络选项卡来修复此问题,并使用您的 'url' 值来调试问题$('selector').load( 'url', function(response, status, xhr){})
| 归档时间: |
|
| 查看次数: |
3410 次 |
| 最近记录: |