Bug Tracker

Ticket #1432 (new enhancement)

Opened 1 year ago

jQuery json

Reported by: hobbit Assigned to: anonymous
Type: enhancement Priority: major
Milestone: 1.1.4 Component: ajax
Version: 1.1.3 Keywords:
Cc: Needs: Review

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.

Attachments

Note: See TracTickets for help on using tickets.