Reputation: 255
I have created a simple contact form and using php via ajax. I passed the url like: /api/index.php where api folder is in the root folder.
$.ajax({ url: "/api/index.php", type: 'POST', data: { 'form_email': this.state.contactEmail, 'form_msg': this.state.contactMessage },
But when I'm submitting form getting 404 error. "Cannot POST /api/index.php"
I need help to call php file via ajax or other method to submit form.
Upvotes: 0
Views: 298
Reputation: 11
I think you need to change the type: 'POST' to method: 'POST'
Upvotes: 1