jQuery ajax post failing in asp

Posted by Dave Kiss on Stack Overflow See other posts from Stack Overflow or by Dave Kiss
Published on 2010-05-24T19:11:36Z Indexed on 2010/05/24 19:21 UTC
Read the original article Hit count: 315

Filed under:
|
|
|
|

hey guys, this might be really stupid, but hopefully someone can help. I'm trying to post to an external script using ajax so i can mail the data, but for some reason my data is not making it to the script.

$(document).ready(function() {
$("#submitContactForm").click(function () {
    $('#loading').append('<img src="http://www.xxxxxxxx.com/demo/copyshop/images/loading.gif" alt="Currently Loading" id="loadingComment" />');
        var name = $('#name').val();
        var email = $('#email').val();
        var comment = $('#comment').val();
        var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment;

        $.ajax({
            url: 'http://www.xxxxx.com/demo/copyshop/php/sendmail.php',
            type: 'POST',
            data: '?name=Dave&[email protected]&comment=hiiii',
            success: function(result) {
                $('#loading').append('success');
                }
            });    

    return false;
});
});

the php script is simple (for now - just wanted to make sure it worked)

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];

$to = '[email protected]';
$subject = 'New Contact Inquiry';
$message = $comment;

mail($to, $subject, $message);
?>

the jquery is embedded in an .aspx page (a language i'm not familiar with) but is posting to a php script. i'm receiving emails properly but there is no data inside. am i missing something? i tried to bypass the variables in this example, but its still not working

thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about ASP.NET