troggy69 troggy69 - 4 months ago 6
Ajax Question

Ajax post value to secondary page

I am trying to post the value of a drop down box to a secondary page through ajax but am getting nothing. I have had a look at some similar issues on here but none really match even though I tried their solutions. The dropdown id is

email_select
and the url I want it sent to is correct. Many apologies but Google isn't helping as much as I'd like. :)

$j(function() {
$j(document).on('change', 'select#email_select', function(event) {
$j.ajax({
type: "POST",
url: "../profile/ajax/email_info.php",
data: {#select_email val(),
},
cache: false,
alert('error');
});
});
});

Answer

#select_email val() means nothing,

Your target is select#mail_select , You should do :

 var data = $('select#email_select').val()
 $j.ajax({
    type: "POST",
    url: "../profile/ajax/email_info.php",
    data: {'mydata' :data},
    cache: false
  });

Check the documentation and see the examples at the bottom http://api.jquery.com/jquery.ajax/