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.
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");