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");
Statement: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