如何
<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>
#为什么
jQuery.load()将使您了解文档。.load 相当于这个
它大致相当于 $.get(url, data, success ) ,只是它是一个方法而不是全局函数,并且它有一个隐式回调函数。当检测到成功响应时(即当 textStatus 为“success”或“notmodified”时),.load() 将匹配元素的 HTML 内容设置为返回的数据。
您需要注册$.ajax( complete:function(responseText, textStatus, XMLHttpRequest)){});
并检查textStatus
价值。如果可以,然后自己将数据加载到目的地$('selector')
。或者.load()
通过在 chrome (ctrl + shift +j) 中观看您的网络 xmlHttpRequests 或 firebug 中的某个网络选项卡来修复问题,并使用您的 'url' 值调试问题$('selector').load( 'url', function(response, status, xhr){})