PDA

View Full Version : [CLOSED][3.0.1] Ext.Ajax.request causes firefox error when no entity returned



kjleng
26 Aug 2009, 10:21 AM
Ext version tested:

Ext 3.0.1 Release


Adapter used:

ext


css used:

only default ext-all.css




Browser versions tested against:

Firefox 3.0.13


Operating System:

Ubuntu 9.04
WinXP Pro SP3


Description:

When Making PUT/POST/DELETE request through Ext.Ajax.request, firefox throws an error, "no element found" on the URL when no entity is being returned by the server.
The issue does not appear using Ext 2.2.1
Workaround is to have the server return a string. But in the case of the provided example server(restlet), the put, post, and delete representation handlers do not have return types.(Though responses can still be set.)


Test Case:

Javascript


Ext.Ajax.request({
url: '/bug/1',
method: 'DELETE',
success: function(response){
Ext.Msg.alert("DELETE","DELETE Successful.");
},
failure: function(response){
Ext.Msg.alert("DELETE","DELETE Failed.");
}
});


Java Resource


@Override
public void removeRepresentations() throws ResourceException {

//Do Something


//Workaround for the bug
//this.getResponse().setEntity(new StringRepresentation("{}"));

//Success Code will be returned
}


An Example Server with java source is available here: http://dl.getdropbox.com/u/1844040/Ext3BugReporting01.zip Read included README for startup instructions


Steps to reproduce the problem:

Run included server jar file specifying the running directory and http port to run on
Navigate to http://localhost:{port} in Firefox
Click on one of the Ext Buttons on the index page
Open Firefox's javascript console to see the result


The result that was expected:

No errors


The result that occurs instead:

"no element found" error is thrown


Screenshot or Video:

Error Console Image Attached
Example Page Image Attached


Debugging already done:

Found Server Side workaround: http://extjs.com/forum/showthread.php?t=77883
No ExtJS debugging has been done


Possible fix:

not provided

evant
26 Aug 2009, 10:53 PM
I can't confirm this.

I modified the restful example in the 3.x download.

js:


Ext.Ajax.request({
url: 'app.php/users/5',
method: 'DELETE',
success: function(response){
Ext.Msg.alert("DELETE","DELETE Successful.");
},
failure: function(response){
Ext.Msg.alert("DELETE","DELETE Failed.");
}
});


Modified the destroy function on the server:


public function destroy() {
$res = new Response();
if (User::destroy($this->id)) {
$res->success = true;
$res->message = 'Destroyed User ' . $this->id;
} else {
$res->message = "Failed to destroy User";
}
return '';
return $res->to_json();
}


The response, as you can see, returns nothing. However the success method is still called.

evant
26 Aug 2009, 10:55 PM
This might be useful:

http://james.revillini.com/2006/10/27/no-element-found-in-firebug-or-firefox-javascript-console/

kjleng
27 Aug 2009, 10:20 AM
EDIT: I will see if the media type changes things.

I had just assumed it was a Bug when it works fine in Ext 2

Nope, I still get the error, on multiple computers using the restlet server.

The issue appears to be the content type. Even though nothing is returned from your PHP request, your content-type was set in your header, I imagine. In the case of the restlet server I have provided, it does not set a content type in the header unless it has content to return.

kjleng
27 Aug 2009, 3:00 PM
Should I repost as a new bug, as the doesn't occur when no entity is returned, it happens when no content type is set?

evant
27 Aug 2009, 9:52 PM
It would be helpful if you could setup a public viewable page.

kjleng
28 Aug 2009, 3:17 PM
http://carbonetworks.com:8008/

The PUT example will not throw an error because I have set it to return a blank string. (Just like your PHP example)

If you are able to look at the response header you will see content-type set for the PUT request.

The other two examples will throw the no element found error in firefox, and if you look at the response header you will not see a content-type set.

evant
30 Aug 2009, 7:57 PM
I just went to your test page and I didn't see any errors thrown.

See the attached image.

kjleng
31 Aug 2009, 8:40 AM
Hmm, Firebug does not seem to show the error, but the error is still in the builtin firefox console Tools->Error Console

Very odd...

I would argue that it is a firefox issue, but I have no idea why it isn't happening with Ext 2.2.1

kjleng
17 Sep 2009, 9:47 AM
Looks like it is a Firefox issue, somehow it's avoided in Ext 2.

According to http://www.w3.org/TR/XMLHttpRequest , responses without Content-Types should default to the text/xml content type. (Makes sense, it is an XMLHttpRequest). But if the entity body is null, the responseXML should return null.

So that leads us to the same issue that you linked to above.

If you look at the response in firebug for my examples you will see that it has a responseXML object, and if you dive into that object you see 'parse error' on some of the objects.

It appears that firefox is not handling the response entity body being null.

kjleng
13 Oct 2009, 10:15 AM
We have now logged it as a bug in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=521301

mjlecomte
18 Oct 2009, 8:56 AM
I'm going to update the status to CLOSED since you've logged this problem to firefox.

haidaoxa2004
26 Nov 2009, 1:42 AM
when i user Ext.Ajax.request request a file aspx, file aspx execute insert data into sql server the firefox message erro "no element found". (this is message file aspx return no object).

Help me! Thanks