jquery Ajax function Execution order problem how to set up synchronization

Source: Internet
Author: User

JavaScript Code

The code is as follows:

function Existproduct (obj) {

var ProductName = Escape (Obj.val ());

$.getjson (".. /product/searchproductbyname.action ", datat,function (data) {

var falg;

Falg = data[0][' existproduct '];

Falg return to no or yes,

return falg;

});

}

function Validateform () {

Alert (existproduct ("#products_name"));

if (Validatenotnull ("#products_name")) {

if (Existproduct ("#products_name")) {

$ ("#productform"). Submit ();

}else{

$ ("#spanproduct"). HTML ("Business name already exists");

}

}else{

$ ("#spanproduct"). HTML ("Business name cannot be empty");

}

}

In this existproduct (obj) function, I call the Getjson function in jquery to return the results of the lookup in the database, which should have no problem with the Firebug, which is outrageous in the execution of the code to execute the returns FALG, And then execute Getjson, please the Master of the guidance

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.