Linking to php file from within JS file.
-
Hi everyone, I am adding a contact form to a wordpress theme site I have developed. I am using Ajax and PHPMailer functions to send mail to myself and the to the recipient.
I have imported the two scripts I need using:
The code I have used in a different XHTML site works fine. However when the page should use AJAX to output a ‘message is submitted’ it doesnt. I just get the standard wordpress ‘page not found’ page template.
I had thought it might be because I am trying to access a php file from the JS file and it is not finding it. A snippet from my JS file:
code
$.ajax({
type: “POST”,
url: “<?php bloginfo(‘template_url’); ?>/bin/process.php”,
data: dataString,
success: function() {
$(‘#contact_form’).html(“<div id=’message’></div>”);
$(‘#message’).html(“<h2>Contact Form Submitted!</h2>”)
.append(“<p>We will be in touch soon.</p>”)
.hide()
.fadeIn(1500, function() {
$(‘#message’).append(“<img id=’checkmark’ src=’../jquery-ajax/js/images/check.png’ />”);
});
}
});
return false;
});
});code
I can see from the source code that JQuery and my two JS files are being loaded fine so I wonder does anyone know how I can get my theme to locate this PHP file?
Thanks
- The topic ‘Linking to php file from within JS file.’ is closed to new replies.