Submit two form by one button and redirect with jQuery Ajax

</pre>
<form id="ajaxform_member" action="" method="post">
<table class="signup-tbl">
<tr>
<td><label for="mname">Name:</label></td>
<td><input type="text" required="" id="mname" name="mname"></td>
</tr>
<tr>
<td><label for="maddress">Address:</label></td>
<td><input type="text" name="maddress" id="maddress" required></td>
</tr>
<tr>
<td><label for="mphone_num">Phone Number:</label></td>
<td><input type="text" name="mphone_num" id="mphone_num" required></td>
</tr>
<tr>
<td><label for="memail">Email:</label></td>
<td><input type="email" name="memail" id="memail" required></td>
</tr>
<tr>
<td><label for="muname">User Name:</label></td>
<td><input type="text" name="muname" id="muname" required></td>
</tr>
<tr>
<td><label for="mpass">Password:</label></td>
<td><input type="password" name="mpass" id="mpass" required></td>
</tr>
</table>
<input  class="signup-tbl-btn" id="form-ajax-submit" type="submit" value="Membership Register"  name="mregister">
<p class="status"></p>
</form>

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="raviradadiya.ommune-facilitator@gmail.com" />
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<!-- Instant Payment Notification & Return Page Details -->
<input type="hidden" name="notify_url" value="http://localhost/JobInterviewGuide/?s2member_paypal_notify=1" />
<input type="hidden" name="cancel_return" value="http://localhost/JobInterviewGuide/" />
<input type="hidden" name="return" value="http://localhost/JobInterviewGuide/?s2member_paypal_return=1" />
<input type="hidden" name="rm" value="2" />
<!-- Configures Basic Checkout Fields -->
<input type="hidden" name="lc" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="custom" value="localhost" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="page_style" value="paypal" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="item_name" value="Bronze Member / description and pricing details here." />
<input type="hidden" name="item_number" value="1" />
<!-- Configures s2Member's Unique Invoice ID/Code  -->
<input type="hidden" name="invoice" value="<?php echo S2MEMBER_VALUE_FOR_PP_INV(); ?>" />
<!-- Identifies/Updates An Existing User/Member (when/if applicable)  -->
<input type="hidden" name="on0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON0; ?>" />
<input type="hidden" name="os0" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS0; ?>" />
<!-- Identifies The Customer's IP Address For Tracking -->
<input type="hidden" name="on1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_ON1; ?>" />
<input type="hidden" name="os1" value="<?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_OS1; ?>" />
<!-- Controls Modify Behavior At PayPal Checkout -->
<input type="hidden" name="modify" value="0" />
<!-- Customizes Prices, Payments & Billing Cycle -->
<!--<input type="hidden" name="amount" value="0.01" />-->
<input type="hidden" name="src" value="1" />
<input type="hidden" name="srt" value="" />
<input type="hidden" name="sra" value="1" />
<!--<input type="hidden" name="a1" value="0" />-->
<!--<input type="hidden" name="p1" value="0" />-->
<!--<input type="hidden" name="t1" value="D" />-->
<input type="hidden" name="a3" value="0.01" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="M" />
<!-- Displays The PayPal Image Button -->
<input class="paypal"  type="submit" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" style="width:auto; height:auto; border:0;" alt="PayPal" />
</form>
<pre>

ajax.signup.js

</pre>
jQuery(document).ready(function($) {
// Perform AJAX send mail and create user on form submit
$('form#ajaxform_member').on('submit', function(e){
$('form#ajaxform_member p.status').show().text(ajax_signup_object.loadingmessage);
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_signup_object.ajaxurl,
data: {
'action': 'member', //calls wp_ajax_nopriv_ajaxsignup
'mname': $('form#ajaxform_member #mname').val(),
'maddress': $('form#ajaxform_member #maddress').val(),
'mphone_num': $('form#ajaxform_member #mphone_num').val(),
'memail': $('form#ajaxform_member #memail').val(),
'muname': $('form#ajaxform_member #muname').val(),
'mpass': $('form#ajaxform_member #mpass').val(),
},
success: function (response) {
//window.location.href='http://localhost/JobInterviewGuide/paypal.php';
}
});
e.preventDefault();
});
$(".paypal").click(function(){
alert("The paragraph was clicked.");
$("#form-ajax-submit").trigger("click");
//$("paypal").trigger("click");
});
});
<pre>
Advertisements

Tagged: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: