且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jquery ajax的问题​​获取函数响应数据

更新时间:2022-06-05 09:09:39

.get(serviceUrl + ?q = + keyword, function (数据,状态){
if (status == ' success'){
.get(serviceUrl + "?q=" + keyword, function (data, status) { if (status == 'success') {


.each(data, function (index,item){
returnString = item.keymatchterm;
returnString = encodeURIComponent(returnString);
});
}
}, json) ;
.each(data, function (index, item) { returnString = item.keymatchterm; returnString = encodeURIComponent(returnString); }); } }, "json");





示例响应输出:data =[{keymatchterm:Axis}],status =成功



当使用



Sample Response Output: data = "[{"keymatchterm":"Axis"}]", status = "success"

When using the


.each时,数据将被重复为



index = 0,item =[而不是 {keymatchterm:Axis }



我无法找出导致此问题的原因。

任何建议这将有很大的帮助。



提前谢谢



我尝试过:



最初数据类型未包含在
.each, the data is getting iterated as

index = 0, item = "[" rather than {"keymatchterm":"Axis"}

I'm not able to find out what could be the reason for this issue.
Any suggestions on this would greatly help.

Thanks in advance

What I have tried:

Initially the data type was not included as a part of

的一部分中