Skip to content

Instantly share code, notes, and snippets.

@rickydazla
Created December 10, 2015 03:13
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rickydazla/45a3c719cfb498997d7b to your computer and use it in GitHub Desktop.
Save rickydazla/45a3c719cfb498997d7b to your computer and use it in GitHub Desktop.
Shopify AJAX Form submit
/* Build the Shopify Parameters
//---------------------------------------*/
var action = '/contact?';
action += encodeURIComponent('form_type') +'='+ encodeURIComponent('contact');
action += '&'+ encodeURIComponent('utf8') +'='+ encodeURIComponent('✓');
action += '&'+ encodeURIComponent('contact[email]') +'='+ encodeURIComponent(contact_email);
action += '&'+ encodeURIComponent('contact[body]') +'='+ encodeURIComponent(contact_body);
/* Submit the form
//---------------------------------------*/
$.ajax({
type: "POST",
async: true,
url: action,
error: function(jqXHR, textStatus, errorThrown) {
// Request Failed.
},
success: function(response) {
// Assume Success. 'response' is the complete HTML page of the
// contact success form, so likely won't be helpful
self.submit_thankyou();
}
});
@luukee
Copy link

luukee commented Jul 31, 2019

What does the '/contact?' action refer to?

@rickydazla
Copy link
Author

@luukee the form's action value

@jofii
Copy link

jofii commented Dec 14, 2020

/contact?form_type=customer&utf8=%E2%9C%93&contact%5Bemail%5D=&contact%5Btag%5D=new%20year%20subscribe
why Status Code: 429 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment