$(function () {
$. Ajax ({
Type: "get",//request
Url: "IndexHello",//send the request address
Async: true,//
//sent to the server data
DataType: "json",//the server returns the data type of the
Success: function (date) {//request after the completion of the call of the callback function, no matter success or failure,
If (date. Islogin=="1") {
Var username=date. The username;
$(" # helllogin "). Append (" & lt; li> " );
} else {
$(" # helllogin "). Append (" & lt; li> " );
}
}
})
});
As shown in figure need to refresh the page to show the login button, or the username in json, this how to solve
CodePudding user response:
Async: true this default is asynchronous,The console. The log (date. Islogin) print and see what's in the under value,
CodePudding user response:
Ajax asynchronous apis, such as response will appear, see the browser console information, or write a debugger to debug in success,CodePudding user response:
You send a synchronous request, that is, to refresh a guy, asynchronous to support local refresh, sometimes I have to cancel the default behavior