所以我试图做一个简单的AJAX调用(我的第一次尝试),返回MySQL表字段中的最高值。我收到错误“Object of class DB_Result could not be converted to string
”,我认为这与序列化有关?
我在查询后尝试了$a = [query here], doing serialize($a), which gave me the output O:9:"DB_Result":1:{s:3:"res";i:0;}
我不确定这意味着什么,但我想要返回的只是一个int。
任何帮助表示赞赏:)
答案 0 :(得分:1)
在php中使用json_encode对db_result进行编码
使用以下代码检索json结果:
$.ajax({
type: "GET",
url: "",
processData: true,
data: {},
dataType: "json",
complete: function(){ },
success: function() {}
});