i trying post values of form 2 databases. 1 of them local, 1 not. it's "backup" client.
my problem have use "post" method , pass values 2 different scripts. have no idea how can that. server not support curl
this using :
<form action="" method="post" enctype="multipart/form-data" id="form"> <table cellspacing='0' onkeydown='return editingkeydown(event);'> <tr><th>first_name<td class='function'>*<td><input value='' maxlength='100' size='40' id='first_name' name='first_name'> <tr><th>last_name<td class='function'>*<td><input value='' maxlength='100' size='40' id='last_name' name='last_name'> <tr><th>company<td class='function'>*<td><input value='' maxlength='100' size='40' id='company' name='company'> <tr><th>phone<td class='function'>*<td><input value='' maxlength='100' size='40' id='phone' name='phone'> <tr><th>email<td class='function'>*<td><input value='' maxlength='100' size='40' id='email' name='email'> <tr><th>zip<td class='function'>*<td><input value='' maxlength='100' size='40' id='zip' name='zip'> <tr><th>street<td class='function'>*<td><input value='' maxlength='100' size='40' id='street' name='street'> <tr><th>city<td class='function'>*<td><input value='' maxlength='100' size='40' id='city' name='city'> <tr><th>state<td class='function'>*<td><input value='' maxlength='100' size='40' id='state' name='state'> <tr><th>country<td class='function'>*<td><input value='' maxlength='100' size='40' id='country' name='country'> <tr><th>reasons<td class='function'>*<td><input value='' maxlength='300' size='40' id='reasons' name='reasons'> <tr><th>notes<td class='function'>*<td><input value='' maxlength='300' size='40' name='notes' id='notes'> <tr><th>callback<td class='function'>*<td><input value='' maxlength='100' size='40' id='callback' name='callback'> </table> <p> <input type='submit' value='salvează' onclick='javascript: return submitform()'> </form> <script type='text/javascript'> function submitform() { if(document.forms['form'].onsubmit()) { document.forms['form'].action='http://www.example.com/script1.php'; document.forms['form'].submit(); document.forms['form'].action='preproc.php'; document.forms['form'].submit(); } return true; } </script> this not working me. know of way can this? alternatives...
thank answers.
try using jquery.deferred(); (https://api.jquery.com/category/deferred-object/)
this way requests sent @ same time, faster:
$( "#some-form" ).on( "submit", function( e ) { e.preventdefault(); var formonedeferred = $.post({ ... }), formtwodeferred = $.post({ ... }); /** * handler triggered if , when both submits succeed */ $.when( formonedeferred, formtwodeferred, function( firstsubmitresults, secondsubmitresults ) { console.log('process submit results', firstsubmitresults, secondsubmitresults ); }); });
Comments
Post a Comment