Side navigation
#955 closed bug (worksforme)
Opened February 13, 2007 09:07PM UTC
Closed July 20, 2007 10:03PM UTC
$ajax({dataType: 'html' (but should be 'script') .... works in safari, but not ff
Reported by: | stevenbristol@gmail. | Owned by: | |
---|---|---|---|
Priority: | trivial | Milestone: | 1.1.4 |
Component: | ajax | Version: | 1.1.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
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.
Attachments (0)
Change History (2)
Changed May 02, 2007 12:42AM UTC by comment:1
Changed July 20, 2007 10:03PM UTC by comment:2
description: | 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.\ → 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. \ |
---|---|
milestone: | → 1.1.4 |
need: | → Review |
resolution: | → worksforme |
status: | new → closed |
version: | 1.1 → 1.1.3 |
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.