开发者

How to get the JSON array from server to Jquery mobile application

开发者 https://www.devze.com 2023-03-18 18:17 出处:网络
I have a REST based webservice which returns json array like [{\"name\":\"abc\",\"age\":\"24\",\"gender\":\"female\"}]. I used this webservice from my Jquery Mobile application like

I have a REST based webservice which returns json array like [{"name":"abc","age":"24","gender":"female"}]. I used this webservice from my Jquery Mobile application like

$.getJSON("http://localhost:8080/webservice/name", { name: +$("na开发者_如何转开发me") }, function(resultList){
    alert("JSON Data: " + resultList.age);
  }); 

But I am getting "undefined" in my alert box. How to return the JSON Array from webservice. What could be the issue here?


Please try this and see if it works:

$.getJSON("http://localhost:8080/webservice/name", { name: +$("name") }, function(resultList){
     $.each(resultList, function(key, val) {
          alert("JSON Data: key" + key + " value: " + value);
     });
}); 
0

精彩评论

暂无评论...
验证码 换一张
取 消