I'm trying to write a simple JSON post and the callback alert does not show up no matter what I do. I used firebugs to see if the post was getting any response and "SHOE" returns. So why is the alert not working in the callback?
view code:
$('#GaragePartAddfrompartlistForm').click(function() {
var item = "CHEESE";
$.post("garage_parts/getlastid", { 'item' : item },
function(data){
alert(data.result);
}, "json");
});
controller code:
function getlastid() {
$newid = "SHOE";
$array = array('result' => $newid);
echo json_encode($array);
}