#128 ✓ duplicate
Chris Henry

String#evalJSON throwing a TypeError

Reported by Chris Henry | May 29th, 2008 @ 09:17 PM | in 1.7

I'm using prototype in conjunction with Extjs to build out an Ajax-driven app. I'm noticing that occasionally there will be Ajax Requests that will occasionally not complete. After some investigation, I found that when I made the call to String#evalJSON, it will throw a TypeError with the following message :

transport.responseText has no properties.

When this happened, I use firebug to log both the error and the

transport object. When I inspect the transport object,

transport.responseText is definitely there, and well-formed.

Here's some sample code:

new Ajax.Request(url, {

method : 'post',

parameters : params,

onComplete : function(transport) {

var myJSON = jsonTransport(transport);

//do stuff with myJSON

}

});

function jsonTransport(transport) {

try {

return transport.responseText.evalJSON();

} catch (e) {

console.log(e, transport)

}

}

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Pages