• 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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter nathan2o12

    (@nathan2o12)

    Further information I have actually got the JQuery ajax message to appear now but I had to replace the code in the header from <?php wp_enqueue_script("jquery"); ?> with<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-1.2.3.pack.js">

    So i assume its something to do with the version of JQuery? I need to use the version jquery-1.2.3.pack.js but I would have imagined the version from within wordpress would have been newer and still worked. Anyone know why this is?

    Thanks

    Switch with another version.

    Thread Starter nathan2o12

    (@nathan2o12)

    How?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Linking to php file from within JS file.’ is closed to new replies.