AJAX and Pretty Permalinks
-
On my new WordPress driven portfolio site, I’m making my contact form submit using AJAX. I want my AJAX functionality to be backed up by inherent loading functionality. I have created a PHP widget that houses my email handling code. I want to be able to include this widget both in the contact page itself and in the off page fragment the ajax calls to to send the email without reloading the page so that I can edit the code in one place if I need to and have it affect both forms of functionality.
Everything I’m doing works except for the part where I need the ajax call to be able to access a different page in my wordpress structure. I need my ajax to work something like this:
$.ajax({ type: "POST", url: 'https://code-junkie.com/wp/portfolio/shard', data: "p=239&sent=" + $("form#contact-me-form #sent-field").val() + "&name=" + $("form#contact-me-form #name-field").val() + "&email=" + $("form#contact-me-form #email-field").val() + "&subject=" + $("form#contact-me-form #subject-field").val() + "&message=" + $("form#contact-me-form #message-field").val(), success: function(data) { $('#contact-me').html(data); } }); return false;
The problem is that it doesn’t work and Firebug is reporting that the page I’m trying to call off to doesn’t exist. Even if I try to make it work by setting the url to: ‘https://code-junkie.com/wp/index.php’ it reports a 404 error in the console.
Does anyone know how I can make an ajax call actually access a different post in WordPress without receiving a 404 error?
- The topic ‘AJAX and Pretty Permalinks’ is closed to new replies.