Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all I explain why you code don't work like you expect.</p> <p>The method <code>$.get</code> works <em>asynchronous</em>. So</p> <ul> <li>your function <code>beforeSubmit</code> first start <code>$.get</code></li> <li>then it returns <code>undefined</code> value bacause the body of the <code>beforeSubmit</code> function will be finished.</li> <li>Then after the asynchronous <code>$.get</code> request will get response from the server the <code>function(data) {</code> callback will be called (it's <code>success</code> callback).</li> <li>Your <code>success</code> callback return the value <code>return[false,"Exists"];</code> <em>from the callback</em>. The <code>$.get</code> don't analyse any return value from the <code>success</code> callback so the array <code>[false,"Exists"]</code> will be discarded by <code>$.get</code>.</li> </ul> <p>You can use <code>$.ajax</code> with <code>async: false</code> parameter instead of <code>$.get</code> as the workaround, but better is don't implement any <code>beforeSubmit</code> at all. If your server-based code find out that the user changes can't be saved or the input field contains some validation errors the server should just return response having some <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes" rel="nofollow noreferrer">error HTTP status code</a>. The status code can be 400 or higher in case of validation errors - <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error" rel="nofollow noreferrer">the Client Error</a> or be 500 or higher in case of some other errors in processing the request on the server - <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_Error" rel="nofollow noreferrer">Server Error</a>. The body of the server response can be HTML fragment of the message which jqGrid will display to the user.</p> <p>You can customize the error message with respect of <code>errorTextFormat</code> callback. See <a href="https://stackoverflow.com/a/5103844/315935">here</a> and <a href="https://stackoverflow.com/a/6803206/315935">here</a> for additional information.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload