Skip to content

Commit

Permalink
Script dataType now supports ecmascript mimetypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaubourg committed Jan 31, 2011
1 parent f286a71 commit e0b1bb8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/ajax/script.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// Install script dataType // Install script dataType
jQuery.ajaxSetup({ jQuery.ajaxSetup({
accepts: { accepts: {
script: "text/javascript, application/javascript" script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
}, },
contents: { contents: {
script: /javascript/ script: /javascript|ecmascript/
}, },
converters: { converters: {
"text script": function( text ) { "text script": function( text ) {
Expand Down
6 changes: 5 additions & 1 deletion test/data/script.php
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php <?php
error_reporting(0); error_reporting(0);
if ( $_REQUEST['header'] ) { if ( $_REQUEST['header'] ) {
header("Content-type: text/javascript"); if ( $_REQUEST['header'] == "ecma" ) {
header("Content-type: application/ecmascript");
} else {
header("Content-type: text/javascript");
}
} }
?> ?>
ok( true, "Script executed correctly." ); ok( true, "Script executed correctly." );
22 changes: 14 additions & 8 deletions test/unit/ajax.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1558,17 +1558,23 @@ test("jQuery.ajax() - malformed JSON", function() {
}); });


test("jQuery.ajax() - script by content-type", function() { test("jQuery.ajax() - script by content-type", function() {
expect(1); expect(2);


stop(); stop();


jQuery.ajax({ jQuery.when(
url: "data/script.php",
data: { header: "script" }, jQuery.ajax({
success: function() { url: "data/script.php",
start(); data: { header: "script" }
} }),
});
jQuery.ajax({
url: "data/script.php",
data: { header: "ecma" }
})

).then( start, start );
}); });


test("jQuery.ajax() - json by content-type", function() { test("jQuery.ajax() - json by content-type", function() {
Expand Down

0 comments on commit e0b1bb8

Please sign in to comment.