javascript - Access return value of JQuery/AJAX on a different function -


I want to access the returned boolean of another function on another function.

  $ ('.set edit'). Change (function () {var asset_id = $ (this) .attr ('id'); var asset = $ ("#" + asset_id) .val (); var data string = "device =" + device + "& asset = "+ Asset; $ .ajax ({type:" POST ", url:" & lt ;? php echo site_url ('c_device / check_assetcode') ;? & gt;, data: datestring, cache: false, success: Function (html) {if (html) returns right; otherwise false return;}}};});  

Is there any way I can access "return true or return false" on my $ (". Edit_tr"). Click (function () function?

In Javascript you call some function names but in jQuery, I do not know how.

You can use global variables;

  var global_status; $ ('. Asset_edit'). Changes (function ( ) {Var asset_id = $ (this) .attr ('id'); var asset = $ ("#" + asset_id) .val (); var data string = "device =" + device + "and asset =" + asset ; $ .jax ({type: "post", url: "& lt ;? php echo site_url ('c_device / check_assetcode') ;? & gt;", day Dotstrings, cache: incorrect, success: function (html) {if (html) {global_status = "true";;} and {global_status = "false"; return back;}}});}); <$ ( Click here (function () {alert (global_states);})  

Here is a working demo:

While doing the test, click Edit first and look undefined, and then select the value from the selectbox and click Edit.


Comments