An example of code with a return value in an ajax request.
Code example with ajax request and return value:
Jquery ajax is widely used to implement some refreshing requests. This section provides a very simple code example for your reference, the Code is as follows:
<Script type = "text/javascript">/* request Ajax with the returned value, and a prompt box pops up to remind ------------------------------------------ */function getAjax (url, parm, callBack) {$. ajax ({type: 'post', dataType: "text", url: url, data: parm, cache: false, async: false, success: function (msg) {callBack (msg) ;}}/* Delete/* url: indicates the Request Path ---------------------------------------------------- */function DeleteData (url, id) {var parm = 'Active = Del & Id = '+ id; if (id = undefined | id = "") {showAlertMsg ('select the row to delete ');} else {showConfirmMsg ("this operation cannot be recovered. Are you sure you want to delete it? ", Function (r) {if (r) {getAjax (url, parm, function (rs) {if (parseInt (rs)> 0) {showOverAlertMsg (" deleted successfully! ",);} Else if (parseInt (rs) = 0) {showOverAlertMsg (" this data is associated and cannot be deleted! ",);} Else {showOverAlertMsg (" deletion failed! ", 2000, 5) ;}}}) }}// delete function DeleteOnclick () {DeleteData ('sysmenu _ List. aspx ', Menu_Id) ;}</script>
Original address: http://www.51texiao.cn/jqueryjiaocheng/2015/0613/4216.html
The most original address is: http://www.softwhy.com/forum.php? Mod = viewthread & tid = 8649.