<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Ajax call inside beforeSubmit</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/ajax-call-inside-beforesubmit</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/ajax-call-inside-beforesubmit/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Ajax call inside beforeSubmit</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/ajax-call-inside-beforesubmit#p31271</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/ajax-call-inside-beforesubmit#p31271</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Â </p>
<p>I recommend you to use async:false in your post ajax function. During this process you can set a wait message.</p>
<p>Â </p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Tue, 21 Oct 2014 18:36:05 +0300</pubDate>
        </item>
        <item>
        	<title>theo121 on Ajax call inside beforeSubmit</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/ajax-call-inside-beforesubmit#p31233</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/ajax-call-inside-beforesubmit#p31233</guid>
        	        	<description><![CDATA[<p>Hi all,</p>
<p>After days of madness I finally ask for help,</p>
<p>Before validate form i need to send a file with postdata to an ftp , wait response and if it's ok validate form in jqgrid , else display form error message.</p>
<p>for that i try to use beforesubmit</p>
<p>send_ftp.php return json data if Ok, html text if it fail.</p>
<p>beforeSubmit : function(postdata, formid) {</p>
<p>var Res = false;<br />
 $.post( 'send_ftp.php', { InfoCl: postdata })<br />
 .done(function( data ) {<br />
 try {<br />
 jQuery.parseJSON(data);<br />
 } catch(error) {<br />
 Res = false;<br />
 }<br />
 var obj = jQuery.parseJSON( data );<br />
 if(obj.type == null &#124;&#124; obj.mut == null) {<br />
 Res = false;<br />
 }else{<br />
 Res = true;<br />
 }<br />
 }<br />
 return[Res];<br />
}</p>
<p>but $.post is asynchronous call so script continue to run and Res is always False.</p>
<p>i do not want to use async false cause it lock browser and can't dislay blockUI before request to prevent user</p>
<p>what i'v try too is </p>
<p>beforeSubmit : function(postdata, formid) {<br />
 $(document).ajaxStop($.unblockUI);<br />
 $.blockUI({ message: '&#60;h1 class=\"spinner\"&#62;&#60;img src=\"../images/busy_small.gif\" /&#62; Send <a href="http://FTP...&#60;/h1&#038;gt" rel="nofollow" target="_blank"></a><a href="http://FTP" rel="nofollow" target="_blank">http://FTP</a>...&#60;/h1&#038;gt;' });<br />
 $.post( 'send_ftp.php', { InfoCl: postdata })<br />
 .done(function( data ) {<br />
 var Res;<br />
 try {<br />
 jQuery.parseJSON(data);<br />
 } catch(error) {<br />
 TriggerError('list1', 'Error FTP');<br />
 }<br />
 var obj = jQuery.parseJSON( data );<br />
 if(obj.type == null &#124;&#124; obj.mut == null) {<br />
 TriggerError('list1', 'Error FTP');<br />
 }else{<br />
 // Here i must validate form manually!<br />
 } </p>
<p> }<br />
 return(false);<br />
}</p>
<p>function TriggerError(tbgrid, texte)<br />
 {<br />
 $("#FormError&#62;td","#TblGrid_"+tbgrid).text(texte);<br />
 $("#FormError&#62;td&#62;ul","#TblGrid_"+tbgrid).css({'list-style-type': 'disc', 'list-style-position': 'outside'});<br />
 $("#FormError","#TblGrid_"+tbgrid).show();<br />
 } </p>
<p>this wotk but after that i must manually validate the form , do not know if it's possible </p>
<p> any idea how can achieve that in any ways ? </p>
<p> regards to all and sorry for my bad english</p>
]]></description>
        	        	<pubDate>Fri, 17 Oct 2014 13:30:58 +0300</pubDate>
        </item>
</channel>
</rss>