Bug Tracker

Opened 16 years ago

Closed 13 years ago

#1432 closed enhancement (fixed)

jQuery json

Reported by: hobbit Owned by:
Priority: major Milestone: 1.1.4
Component: ajax Version: 1.1.3
Keywords: Cc:
Blocked by: Blocking:

Description

We modified the httpData method to can parse the json object with $.json object if exists and can get the x-json header.

.httpData : function( r, type ){
  var ct = r.getResponseHeader("content-type"),
      data = (type=="xml || (!type && ct && ct.indexOf("xml") >= 0)?
      r.responseXML:r.responseText;

  switch (type){
  case "script":
    jQuery.globalEval( data );
    break;

  case "json":
    data = r.getResponseHeader('X-JSON') || data;
    data = $.JSON? $.JSON.parse(data):eval("(" + data + ")");
    break;

  case "html":
    jQuery("<div>").html(data).evalScripts();
    break;
  }

  return data;
}

The modified script explains the x-json header like prototype library, and we can use the JSON plugin if it is defined.

Change History (1)

comment:1 Changed 13 years ago by dmethvin

Resolution: fixed
Status: newclosed

This was implemented in 1.4.

Note: See TracTickets for help on using tickets.