I absolutely cannot get this to work. I’ve tried many different solutions from different decoding in my PHP to using $.post and $.getJSON but I absolutely cannot get my ajax to work. On my main AJAX Page’s network it is Requesting Payload “names%5B%5D=John+Doe&names%5B%5D=Jane+Doe&names%5B%5D=Josh+Doe” - which should be fine and dandy. The problem is my [URL=“http://www.webdevstl.com/misc/ajax/names.php”]PHP Page keeps showing NULL. I’ve been trying many different things the last few days, any insight would be helpful.
Here’s my Javascript - I’m running JQuery 1.7.2
var fullName = ["John Doe", "Jane Doe", "Josh Doe"];
$(window).load(function(){
getList();
});
function getList(){
$.ajax({
type: "post", /* the request's method: */
url:"names.php", /* the request's location: */
data: {"names[]": fullName}, /* the request's fields: */
contentType: "application/json; charset=utf-8", /* the request's content-type : */
dataType:"json", /* the response's content-type: */
success: function(json){ /* the callback function */
if(json.length != null){
$.each(json, function(i, v){
console.info(v);
});
} else {
alert('wtf?!');
}
}
});
}
and my Simple PHP Page
<?php
urldecode(var_dump($_POST['names[]']));
$names = $_POST['names[]'];
echo json_encode($names);