i have this code:
<script type="text/javascript">
$(document).ready(function() {
function doAjax(url) {
$("#customForm").submit(function() {
var formdata = $("#customForm").serializeArray();
$.ajax({
url: url,
type: "post",
dataType: "json",
data: formdata,
success: function(data) {
switch (data.livre) {
case 'tituloLivre':
$("#msgbox2").fadeTo(200, 0.1, function() {
$(this).html('error').fadeTo(900, 1);
});
break;
default:
$("#msgbox2").fadeTo(200, 0.1, function() {
$(this).html('success!').fadeTo(900, 1, function() {
$('#conteudo').load('test.php'); // show NULL and must be programmer
});
});
break;
}
}
});
return false;
});
}
doAjax('sent.php');
doAjax('dojo/test.php');
});
</script>
test.php
<?php
include ('includesMy.php');
$form = $_POST['item'];
$oferta = $form['oferta'];
var_dump($oferta);
?>
what is sent:
item[oferta] programmer
The question is: why i get null value instead of programmer word ?
POST test.php – returns programmer, but GET test.php returns null. Basically the load (test.php) is retrieved without ajax influence.
The server response should be valid JSON. Use the
json_encodePHP function at the server’s side to return a valid JSON string.