I have a ajax request as below :
$('#student_name').change(function(){
var student_id = $(this).val();
if(student_id!=0){
var url = "ajax_student_bill_details.php";
var data = "id="+student_id;
$.ajax({
type: "GET",
url: url,
dataType : "json",
data: data,
// cache: false,
error : function(result){
alert('Error');
},
success: function(result){
alert(result);
}
});
}
});
And the ajax_student_bill_details is :
$arra = ('a' => 1,'b' => 2);
return json_encode($arra);
But when I change the options it always alerts Error . Whats wrong with my codes ?
EDIT:
$arra = array('a' => 1,'b' => 2);
var_dumpwould givestring '{"a":1,"b":2}' (length=13). Thanks