检查jQuery的AJAX加载成功 [英] Checking Jquery ajax load success

查看:115
本文介绍了检查jQuery的AJAX加载成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直使用加载另一个页面,只是用自己的例子:

I've been using this to load another page, and just using their example :

$("#links").load("/Main_Page #jq-p-Getting-Started li");

不过,我想运行一个功能,当负载是成功的,并且不同的一个,如果它失败了,遗憾的是在回调中描述说:

However I want to run a function when the load is successful, and a different one if it fails, unfortunately the description on the callback says:

称为当AJAX请求完成(不一定成功)的功能。

The function called when the ajax request is complete (not necessarily success).

我如何确保负载是成功的?

How do I make sure the load was successful?

感谢。

推荐答案

您可以尝试使用更详细的$。阿贾克斯()方法调用。这会给你更细粒度的控制AJAX调用(但也需要有点不是一个简单的.load更多的工作()),它可以让您根据您的电话是否返回成功或错误的调用不同的功能。

You might try using the more detailed $.ajax() method call. This will give you more fine-grained control over the AJAX call (but it also requires a bit more work than a simple .load().) It will allow you to call different functions based on whether your call returns success or error.

退房: http://docs.jquery.com/Ajax/jQuery.ajax #options ,获取有关该功能的文档。如果你点击页面上的选项标签,你会得到的参数的完整列表,你可以传递给$阿贾克斯()函数。

Check out: http://docs.jquery.com/Ajax/jQuery.ajax#options for documentation on this function. If you click the "Options" tab on that page, you will get a full listing of the parameters that you can pass to the $.ajax() function.

这篇关于检查jQuery的AJAX加载成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆