Writing return directly in ajax in the function addSglr() method does not take effect;
Because it returns the success method in ajax, not addSglr().
Therefore, a global variable can be set for judgment to achieve the effect of stopping.
Note: Ajax must be synchronous.
function addSglr(){
var flag = false;//Global variable for the following judgment
var addr;
$.ajax({
type : “post”,
url : ctx + “/admin/zklt/basebook/getBaseBySfzh”,
data : {sfzh:card_number},
dataType: ” json “,
async: false,//It must be a synchronous request, otherwise it will jump; (ajax is asynchronous by default)
success : function(result) {
if(null != result){
if(result.szsq != …
The post Ajax return does not take effect solution first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/9199
This site is for inclusion only, and the copyright belongs to the original author.