Home > Web Front-end > JS Tutorial > body text

Jquery ajax execution sequence returns custom error message (explanation with examples)_jquery

WBOY
Release: 2016-05-16 17:17:18
Original
934 people have browsed it

1. Execution order of multiple Ajax in one function

Since the async of Ajax in Jquery is true by default (asynchronous request), if you want to execute another Ajax after one Ajax is executed, you need to set async=false.

Copy code The code is as follows:

function TestAjax(){
      var UserName = $("#txtUserName").val() ;
            $.ajax(
                                                                     success: function (data) {
alert(data);
                                                                                                            🎜>           async: false,
               data: " UserName=" UserName,
success: function (data) {
                                                       (msg) {
alert (msg.responseText);
                                                                                                                                                               ;
Set StatusCode = 500,

Trigger Ajax error, display custom information after receiving data




Copy code


The code is as follows:

error: function (msg) {
                                                                                                                                                                                 ; context.Response.StatusCode = 500; context.Response.Write("Please enter username");


string sUserName = context.Request.QueryString["UserName"];
if (!string.IsNullOrEmpty(sUserName))
                                                                                                                                                                                                                                   {
context.Response.StatusCode = 500 ;
                  context.Response.Write("Please enter user name");
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!