I'm writing an ajax application and have a function in a php script:
public function expire_user() {
$r=array("return"=>'OK');
echo json_encode($r);
}
that gets called with this javascript:
$.getJSON("/users/expire_user",function(data){
alert('success');
});
The problem is that the alert never displays. I think this is due to json_encode returning invalid json, because when I go to the url directly, it displays
{"return":"OK"}[]
which is not valid json due to the extra '[]' on the end. Why is json_encode putting the empty array on the end and how do I get rid of it so that I can receive valid json?