Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery & ajax autorize.net submit
    text
    copied!<p>Hey all i am trying to figure out why i keep getting the error </p> <p><strong>here was an error submitting the form. Please try again. parsererror</strong> </p> <p>when trying to submit my form to authorize.net</p> <p>My <strong>authsubmit</strong> php code is this:</p> <pre><code> &lt;?PHP require_once 'anet_php_sdk/AuthorizeNet.php'; // Make sure this path is correct. $transaction = new AuthorizeNetAIM('xxxxxxx', 'xxxxxxx'); $post_url = "https://secure.authorize.net/gateway/transact.dll"; $transaction-&gt;amount = $_POST['amount']; $transaction-&gt;card_num = $_POST['card_num']; $transaction-&gt;exp_date = $_POST['exp_date']; $transaction-&gt;first_name = $_POST['first_name']; $transaction-&gt;last_name = $_POST['last_name']; $transaction-&gt;card_code = $_POST['cvv']; $transaction-&gt;address = $_POST['address']; $transaction-&gt;city = $_POST['city']; $transaction-&gt;state = $_POST['state']; $transaction-&gt;zip = $_POST['zip']; $transaction-&gt;invoice_num = $_POST['invoice_num']; //$transaction-&gt;currency_code = $_POST['currency']; $response = $transaction-&gt;authorizeAndCapture(); if ($response-&gt;approved) { echo "&lt;h1&gt;Success! The test credit card has been charged!&lt;/h1&gt;"; echo "Transaction ID: " . $response-&gt;transaction_id; } else { echo "here is the error: " . $response-&gt;error_message; } ?&gt; </code></pre> <p>And my <strong>authsubmit</strong> php code:</p> <pre><code> &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#frm1").submit(function(){ $.ajax({ type: "POST", url: "authsubmit.php", data: $("#frm1").serialize(), dataType: "json", success: function(msg){ alert("DONE! " + msg); }, error: function(obj, status, e){ alert("There was an error submitting the form. Please try again. " + status); } }); return false; }); }); &lt;/script&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="frm1" method="post"&gt; &lt;fieldset&gt; &lt;div&gt; &lt;label&gt;Invoice Amount&lt;/label&gt; &lt;input type="text" value="3.33" name="amount" size="15" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Invoice Number&lt;/label&gt; &lt;input type="text" value="23111" name="invoice_num" size="15" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Credit Card Number&lt;/label&gt; &lt;input type="text" value="4500000000009000" name="card_num" size="15" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Exp.&lt;/label&gt; &lt;input type="text" value="1212" name="exp_date" size="4" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;CCV&lt;/label&gt; &lt;input type="text" value="782" name="cvv" size="4" class="text"&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;div&gt; &lt;label&gt;First Name&lt;/label&gt; &lt;input type="text" value="bob" name="first_name" size="15" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Last Name&lt;/label&gt; &lt;input type="text" value="barker" name="last_name" size="14" class="text"&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;div&gt; &lt;label&gt;Address&lt;/label&gt; &lt;input type="text" value="123 street" name="address" size="26" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;City&lt;/label&gt; &lt;input type="text" value="hyyon" name="city" size="15" class="text"&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;fieldset&gt; &lt;div&gt; &lt;label&gt;State&lt;/label&gt; &lt;input type="text" value="ca" name="state" size="4" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Zip Code&lt;/label&gt; &lt;input type="text" value="45098" name="zip" size="9" class="text"&gt; &lt;/div&gt; &lt;div&gt; &lt;label&gt;Country&lt;/label&gt; &lt;input type="text" value="US" name="currency" size="22" class="text"&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;input type="submit" value="Submit form" /&gt; &lt;div class="form_result"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>What am i missing here?</p> <p>David</p>
 

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