我正在查看 Ben 的示例 @ http://www.bennadel.com/blog/1515-Ask-Ben-Building-An-AJAX-jQuery-And-ColdFusion-Powered-Application.htm并讨论了一个超简单的示例我自己的。但似乎即使 CFC 返回格式正确的 JSON,它总是在我的错误处理程序中以错误结束:
无效 JSON:{"ERRORS":"","SUCCESS":true,"DATA":"id DEX015-002-00, whs W1, qty 9"}
这是ajax调用
$.ajax({
type: 'GET',
url: 'bridge.cfc',
data: {
method: 'UpdateQty',
id: 'DEX015-002-00',
whs: 'W1',
qty: '9'
},
dataType:'json',
success: function(res, status, req){ alert("Message from server:\n" + "res: " + res); },
error: function(req, status, err){ "Error from server:\n" + "err: " + err); }
});
这是 CFC “bridge.cfc”
<cfcomponent>
<cffunction name="UpdateQty" access="remote" returntype="struct" returnformat="json" output="false">
<cfargument name="id" required="yes" type="string">
<cfargument name="whs" required="yes" type="string">
<cfargument name="qty" required="yes" type="string">
<cfset res = structNew()>
<cfset res.success = true>
<cfset res.data = "id " & arguments.id & ", whs " & arguments.whs & ", qty " & arguments.qty >
<cfset res.errors = "">
<cfreturn res >
</cffunction>
</cfcomponent>
我错过了什么?