The Ajax request data in the js Method is judged and the verification is invalid (OnClientClick = & quot; return Method (); & quot;), or the background code is directly executed.
Function CheckAdd () {var flag = true; $. ajax ({cache: false, async: false, url: "/ajaxpage/getajax. aspx? T = adjserviceclientlist & Cellphone = "+ Cellphone +" & a = "+ Math. random (), ype: 'json', success: function (data) {if (data! = Null) {var result = data ["Remark"]; if (result = 'This number already exists and has been bound to the master number. It cannot be bound again! ') {Alert (result); flag = false;} if (result =' This number already exists. Are you sure you want to bind it to the primary number? ') {If (confirm (' This number already exists. Are you sure you want to bind it to the primary number? ') {$ (' # MainContent_Hiddend_IsExitCellPhone '). val ('1') ;}else {flag = false ;}}}) if (! Flag) {return false ;}}
Problem 1: ajax is asynchronous by default. Therefore, when ajax is executed, the background method is also executed. For example:
Async: "false" indicates synchronization.
Question 2: make a judgment on the data returned by the ajax request. The return false operation cannot be performed directly. A value must be assigned and executed outside the request method. For example:
If (! Flag ){
Return false;
}