简体   繁体   English

运行功能是否成功($ .ajax)具有200状态代码?

[英]run function if success ($.ajax) has 200 status code?

I would like to use success and run function only if has 200 status code I have see only this example: 我仅在具有200个状态代码的情况下才想使用success并运行功能,我仅看到以下示例:

 $.ajax ({
   success: function(data,textStatus,jqXHR){
     external();
   }
 )};

But i never see a really code example i would like the if status code is 200 is run an external function 但是我从来没有看到一个真正的代码示例,我想如果状态代码为200运行外部函数

PS before i tried to use easy success (without arguments) and error, but error worked also if the external file was ok.. PS在我尝试使用简单成功(无参数)和错误之前,但如果外部文件正常,错误也可以工作。

Sorry for my english 对不起我的英语不好

The success event is called when the request succeeds ( documentation ). 请求成功时将调用success事件( documentation )。 The textStatus parameter should contain the string '200' or any other status number your server returned. textStatus参数应包含字符串'200'或服务器返回的任何其他状态编号。

I hope the code you posted is partial: I don't see the url, method, etc. which should be passed as parameters to $.ajax . 我希望您发布的代码是局部的:我看不到url,方法等应作为参数传递给$.ajax

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 成功ajax:如果是200状态码运行功能,否则为另一个功能 - success ajax: if is 200 status code run function else another function AJAX成功:功能始终返回成功(以及200状态代码),错误功能未触发 - AJAX success:function always returning success (and 200 status code), error function not triggering Ajax成功函数不适用于返回的json数据和状态200/304 - Ajax success function not working with returned json data and status 200/304 Ajax成功事件在网络选项卡显示200状态代码的地方不起作用 - Ajax success event not working where network tab showing 200 status code jQuery $ .ajax使用JSONP调用跨域,返回状态200,但是错误函数被调用而不是成功 - jQuery $.ajax call for cross domain with JSONP, returns status 200, but error function is being called instead of success AJAX状态码&lt;400成功吗? - Success with AJAX Status code < 400? ajax谷歌地图-{“ readyState”:4,“ status”:200,“ statusText”:“ success”}} with parsererror - ajax google map - {“readyState”:4,“status”:200,“statusText”:“success”} with parsererror 操作返回状态代码 204 但 AJAX 成功 function 未执行 - Action returns Status Code 204 but, AJAX success function doesn't execute Ajax 200成功/失败执行 - Ajax 200 Success/failed execution Ajax请求仅返回错误,但状态码为200 OK - Ajax Request Only Returns Error But The Status Code Is 200 OK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM