Ticket #955 (closed bug: worksforme)
$ajax({dataType: 'html' (but should be 'script') .... works in safari, but not ff
| Reported by: | stevenbristol@… | Owned by: | |
|---|---|---|---|
| Priority: | trivial | Milestone: | 1.1.4 |
| Component: | ajax | Version: | 1.1.3 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by john) (diff)
Here is my code:
function related_stories_new_page(url, page){
jq.ajax({
dataType: 'html', url: url, data: 'page=' + page, success: function(res){eval(res);}, error: function(){alert('could not retrieve the new page.');} });
return false;
}
The code should be:
function related_stories_new_page(url, page){
jq.ajax({
dataType: 'script', url: url, data: 'page=' + page, success: function(res){eval(res);}, error: function(){alert('could not retrieve the new page.');} }); return false;
}
because the call returns javascript, not html.
When the incorrect dataType is present (first function), Safari will eval the js that is returned anyways, while Firefox will do nothing.
The behavior should be consistent.
They both behave the same with the second function.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Are you saying that FF doesn't eval the response even though you're explicitly invoking eval yourself? I've tried to duplicate this but I can't. In the script below, FF is correctly evaling the text in may1.txt.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <script type="text/javascript" src="jquery-1.1.2.js"></script> <script type="text/javascript"> $(function() { $.ajax({ dataType: 'html', url: 'may1.txt', data: 'page=1', success: function(res){eval(res);}, error: function(){alert('could not retrieve the new page.')} }); }); </script> </head> <body></body> </html>