Reputation: 7479
test.php
$aaa = $_POST['aaa'];
echo $aaa;
Javascript Code
$.ajax({
url: 'ajax/test.php',
data: { aaa: 'names_' },
success: function(data) {
alert("Data Loaded: " + data);
}
});
The alert response is:
NOTICE: Undefined Index: aaa
What might cause this?
Upvotes: 1
Views: 1834
Reputation: 9427
Add to the ajax object the type attribute:
$.ajax({
url: 'ajax/test.php',
type:'post',
data: { aaa: 'names_' },
success: function(data) {
alert("Data Loaded: " + data);
}
});
Upvotes: 4