I think the solution may be something like this
function hi () { $.ajax({ url: "/shop/haveItem", type: "GET", success: function (data) { if (data == '1') { ifData1(); } else { ifDataNot1() } } }); } function ifData1 () { } function ifDataNot1 () { }
If you have an ajax function, you should always work with callback functions. If you make the ajax function synchronous, the browser will be blocked for the duration of the ajax call. This means that the application will remain immune for the duration of the call.
source share