Hi,

I'm using Chrome 14 and when I use Ajax.Request() (Prototype 1.7), I
always get a blank text in response.responseText and so
response.responseJSON is null too, whereas on other browsers this is
working fine.
This issue was already happening in previous versions of Chrome.

This may be an issue on Chrome's side, I don't know. But I've found a
way to fix it by editing :

Ajax.Response.initialize:

    if ((readyState > 2 && !Prototype.Browser.IE) || readyState == 4)
{
      this.status       = this.getStatus();
      this.statusText   = this.getStatusText();
      this.responseText = request._responseText =
((Prototype.Browser.WebKit && request._responseText) ||
String.interpret(transport.responseText)); // change here
      this.headerJSON   = request._headerJSON =
((Prototype.Browser.WebKit && request._headerJSON) ||
this._getHeaderJSON()); // change here
    }


Ajax.Response._getResponseJSON:

    if (!options.evalJSON || (options.evalJSON != 'force' && !
Prototype.Browser.WebKit && // change here
      !(this.getHeader('Content-type') || '').include('application/
json')) ||
        this.responseText.blank())
          return null;



I've let Prototype 1.7 in its original state but I've included a fix
in my main JS file:

if( Prototype.Browser.WebKit ) {
        Ajax.Response.prototype.initialize = function(request){
    this.request = request;
    var transport  = this.transport  = request.transport,
        readyState = this.readyState = transport.readyState;

    if ((readyState > 2 && !Prototype.Browser.IE) || readyState == 4)
{
      this.status       = this.getStatus();
      this.statusText   = this.getStatusText();
      this.responseText = request._responseText =
(request._responseText || String.interpret(transport.responseText));
      this.headerJSON   = request._headerJSON = (request._headerJSON
|| this._getHeaderJSON());
    }

    if (readyState == 4) {
      var xml = transport.responseXML;
      this.responseXML  = Object.isUndefined(xml) ? null : xml;
      this.responseJSON = this._getResponseJSON();
    }
  };
        Ajax.Response.prototype._getResponseJSON = function() {
    var options = this.request.options;
    if (!options.evalJSON || (options.evalJSON != 'force' &&
      !(this.getHeader('Content-type') || '').include('application/
json')) ||
        this.responseText.blank())
          return null;
    try {
      return this.responseText.evalJSON(options.sanitizeJSON ||
        !this.request.isSameOrigin());
    } catch (e) {
      this.request.dispatchException(e);
    }
  };
}

Thanks for your time. And big thanks for Prototype's developpers!!!!
/Lionel

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to