Closed
Bug 736906
Opened 12 years ago
Closed 8 years ago
Using jquery within a javascript does not return json results.
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
Tracking | Status | |
---|---|---|
platform-rel | --- | ? |
People
(Reporter: aevargareg, Unassigned)
References
()
Details
(Whiteboard: [platform-rel-jQuery])
Attachments
(1 file, 1 obsolete file)
1.03 KB,
text/html
|
Details |
When I fire an onclick event to get JSON data, "object XMLData" is returned instead of the data. This procedure works correctly in IE9 and Opera 11.61. I validated my JSON data at http://jsonlint.com/ http://jsonformatter.curiousconcept.com/ You will need a copy of jquery.min.js (version 1.7.1) to test this, as well as my files below. HTML file ========= <!DOCTYPE html> <html lang="en"> <head> <title>Firefox jQuery test page</title> <meta charset="utf-8"/> <meta name="author" content="Alan Varga"/> <meta name="description" content="demonstrate bug in Firefox jquery get"/> <meta http-equiv="last-modified" content="Sun, 18 Mar 2012 12:20 CDT"/> <style> #testlink { color: Blue; background-color: LightGreen;} </style> <script src="jqtest.js"></script> <script src="jquery.min.js"></script> </head> <body> <p> Click <span id="testlink"> <a title="popup hint for link" onclick="showFile();">here</a> </span> to display the contents of the json file in an alert window. </p> <p> In Firefox 11, [object XMLDocument] displays instead of the actual file.<br/> Internet Explorer 9 and Opera 11.61 the file displays, as expected. </body> </html> JSON datafile ============= {"submenus": {"submenu":[ {"name": "submenu1", "item": "test1"}, {"name": "submenu7", "item": "test7"}] } }
Comment 1•12 years ago
|
||
showFile() isn't defined in your testcase, and neither is jqtest.js.
Component: File Handling → Untriaged
QA Contact: file.handling → untriaged
Reporter | ||
Comment 2•12 years ago
|
||
Sorry, I copied my HTML from the wrong open window. Try this one instead, which includes showFile() directly in the HTML: <!DOCTYPE html> <html lang="en"> <head> <title>Firefox jQuery test page</title> <meta charset="utf-8"/> <meta name="author" content="Alan Varga"/> <meta name="description" content="demonstrate bug in Firefox jquery get"/> <meta http-equiv="last-modified" content="Mon, 19 Mar 2012 08:00 CDT"/> <style> #testlink { color: Blue; background-color: LightGreen;} </style> <script src="jquery.min.js"></script> <script> function showFile(){ $.get("jqtest.json", function(data){ alert(data); }); } </script> </head> <body> <p> Click <span id="testlink"> <a title="popup hint for link" onclick="showFile();">here</a> </span> to display the contents of the json file in an alert window. </p> <p> In Firefox 11, [object XMLDocument] displays instead of the actual file.<br/> In Internet Explorer 9, Opera 11.61 and Chrome 17.0 the file displays, as expected. </body> </html>
Reporter | ||
Updated•12 years ago
|
Summary: Using jquery within a javascript does not json results. → Using jquery within a javascript does not return json results.
Comment 3•12 years ago
|
||
Comment 4•12 years ago
|
||
Attachment #607370 -
Attachment is obsolete: true
Comment 5•12 years ago
|
||
I get no alert with Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120319 Firefox/14.0a1 ID:20120319031122 on attachment 607372 [details] - no errors in error console
Comment 6•12 years ago
|
||
The testcase required the json file as well. http://www.joshmatthews.net/json.html is the same testcase, and it passes in Firefox nightly. I suspect this bug has been fixed between FF 11 and nightlies. Alan, can you confirm?
Reporter | ||
Comment 7•12 years ago
|
||
I installed Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120319 Firefox/14.0a1. I have to say this is still unresolved, as my alert still shows [object XMLDocument], instead of the actual data.
Comment 8•12 years ago
|
||
Is that with my testcase? What if you try safe mode?
Comment 9•12 years ago
|
||
WFM with Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120319 Firefox/14.0a1 ID:20120319031122
Reporter | ||
Comment 10•12 years ago
|
||
That's the funny thing... After I retried my test case, which failed, I clicked on your link, and it passed. I thought it might be because you had a different URL for jquery.min.js, or that my local file was cached, so I changed my URL to the googleapis.com link and cleared my browsing history for the last hour. Your testcase works and mine doesn't. I'm now back to Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0 and your testcase works and mine doesn't. This is the way my day has been going. If you have an explanation, I'd appreciate the education. Otherwise, I think you can close this bug report, since you've demonstrated that there isn't an issue.
Reporter | ||
Comment 11•12 years ago
|
||
One further follow-up: I saved the source from your link as a local file, opened it and it failed. Further, I uploaded my testcase, data and a my copy of jquery.min.js to my own webspace, opened it and it passed! Give it a try: http://user.mc.net/~aevarga/tests/FF%20bug/jqtest.htm So it seems that the jQuery functionality is only working if the page is loaded from the Internet.
Comment 12•12 years ago
|
||
That's an excellent datapoint, thanks. This probably has to do with XHRs and file:// URLs.
Component: Untriaged → DOM
Product: Firefox → Core
QA Contact: untriaged → general
Comment 13•12 years ago
|
||
Well, for file:// URIs we will always attempt to parse them as XML, since there is no MIME information for local files. It sounds like whatever you're doing in your jquery code is trying to pick up the responseXML instead of the responseText for some reason.
Reporter | ||
Comment 14•12 years ago
|
||
I was using this mechanism for debugging, but it isn't critical. My data is JSON, but if I infer correctly, I wouldn't have had a problem if I were using XML data instead. You can close this incident, since this is expected behavior I didn't know about. Thanks for investigating.
Updated•8 years ago
|
Whiteboard: [platform-rel-jQuery]
Updated•8 years ago
|
platform-rel: --- → ?
Comment 15•8 years ago
|
||
Closing per Comment #14.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•