What am i doing wrong. PHP doesn’t seem to catch title
and wrapper
from $.ajax. Does the code look correct. The success message i get indicate an error that title is not found.
jQuery main.html
JavaScript
x
$.ajax({
type: "POST",
url: "process.php",
data: 'title=test&wrapper=testing',
success: function(msg){
alert( "Data Saved: " + msg );
}
});
PHP process.php
JavaScript
<?php
$title = $_REQUEST['title'];
$wrapper = $_REQUEST['wrapper'];
?>
Advertisement
Answer
Take a look: jQuery.ajax()
The data parameter is better to be a Key/Value pairs object, it’s cleaner and easier to debug 🙂
JavaScript
$.ajax({
type: "POST",
url: "process.php",
data: {
title: 'test',
wrapper: 'testing'
},
success: function(msg){
alert( "Data Saved: " + msg );
}
});