I am trying to receive a json object back from php after sending data to the php file from the js file.
All I get is undefined.
Here are the contents of the php and js file.
data.php
<?php
$action = $_GET['user'];
$data = array( "first_name" => "Anthony", "last_name" => "Garand", "email" => "[email protected]", "password" => "changeme");
switch ($action) { case '[email protected]': echo $_GET['callback'] . '('. json_encode($data) . ');'; break; }
?>
core.js
$(document).ready(function(){
$.ajax({ url: "data.php",
data: {"user":"[email protected]"},
context: document.body,
data: "jsonp",
success: function(data){renderData(data);}
});
});
function renderData(data) { document.write(data.first_name); }