English 中文(简体)
json对阵列的反应
原标题:json response into an array
  • 时间:2010-09-03 00:29:01
  •  标签:
  • jquery
  • json

What s the best way to get a json response into an array that I can use in the below example? This is my function that calls triggers the ajax call:

function getMaps(){

    mapID = "aus";
    mapImg =  map_australia.jpg ;

    $.ajax({
        type: "GET",
        url: "getMap.asp",
        data: "id=" + mapID,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) { 

          //not sure what to do here        
        }

      });
      return //not sure what to return here 
      // it should resemble: return {id:  aus , image:  /resources/images/maps/map_australia.jpg , data:   , maps: []};

};  

为了测试目的,从中转来:

{ j :[{ id : aus , image : /images/maps/map_detail.jpg , data :  , maps :[]}]}
问题回答
return JSON.parse(response);

如果你再次询问如何处理同步反应,那么你需要调整称作getMaps的代码,因为可以直接退回答复。 相反,你们应当接受退约作为理由。





相关问题
JQuery/MVC Search Issue

I have inherited a piece of work where the entry screen shows a summary of 20 calculated variables. E.g. Var A (250), Var B (79). Clicking on any of these links takes the user to a view with a ...

jQuery quicksearch plug-in tinkering with JSON

I ve implemented the quicksearch plugin by Rik Lomas and I love it for an application in a custom CMS I m building. I was wondering though, since I m going to have a bizillion items in the table if ...

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

PHP json_decode question

i m trying to use json_decode to combine a few json objects and then re-encode it. my json looks like: { "core": { "segment": [ { "id": 7, "...

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string ...

热门标签