How to set up synchronization for ajax function execution order in jquery

  • 2020-03-30 02:11:40
  • OfStack

JavaScript code
function existProduct(obj){ 

var productname = escape(obj.val()); 
var falg; 
falg = data[0]['existproduct']; 
//Falg returns no or yes,
return falg; 


function validateform(){ 
$("#spanproduct").html(" The business name already exists "); 
$("#spanproduct").html(" The business name cannot be empty "); 

In the existProduct(obj) function, I call the getJSON function in jquery to return the result of the search in the database, which should be no problem to check with firebug, but when the code executes, the code first executes return falg, and then executes getJSON

Related articles: