I have no idea why I cannot get jquery to parse a JSON array from a PHP server side call.
Here is my jQuery
$.ajax({
type:"POST",
url:"/Home/Profile/cb_profile.php",
data:{loadProfile: JSON.stringify(itemsToPost)},
success: function(data){
var returnedItem = $.parseJSON(data);
},
error: function(e){
console.log("We've had a error");
},
});
Here is my PHP
if(isset($_REQUEST['loadProfile']))
{
$connection = connectSQL();
$userID = getID();
$query = "SELECT * FROM users where usersID = $userID";
$results = query($connection,$query);
$row = $results->fetch_assoc();
$firstName = "Steve";
echo json_encode(array("firstName" => $firstName));
disconnectSQL($connection);
}
I get this error inside of firebug.
SyntaxError: JSON.parse: unexpected character
return window.JSON.parse( data );
Please help...