jquery ajax: addition for #2452. Wasn't working correctly in some cases.
This commit is contained in:
parent
7638fc5835
commit
cf8c1249d1
2 changed files with 8 additions and 5 deletions
|
@ -113,7 +113,7 @@ jQuery.extend({
|
|||
get: function( url, data, callback, type ) {
|
||||
// shift arguments if data argument was omited
|
||||
if ( jQuery.isFunction( data ) ) {
|
||||
type = callback;
|
||||
type = type || callback;
|
||||
callback = data;
|
||||
data = null;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ jQuery.extend({
|
|||
post: function( url, data, callback, type ) {
|
||||
// shift arguments if data argument was omited
|
||||
if ( jQuery.isFunction( data ) ) {
|
||||
type = callback;
|
||||
type = type || callback;
|
||||
callback = data;
|
||||
data = {};
|
||||
}
|
||||
|
|
|
@ -726,9 +726,10 @@ test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
|
|||
});
|
||||
|
||||
test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
|
||||
expect(4);
|
||||
expect(5);
|
||||
stop();
|
||||
jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
|
||||
ok( json.length >= 2, "Check length");
|
||||
equals( json[0].name, 'John', 'Check JSON: first, name' );
|
||||
equals( json[0].age, 21, 'Check JSON: first, age' );
|
||||
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
|
||||
|
@ -741,8 +742,10 @@ test("jQuery.getJSON(String, Function) - JSON object", function() {
|
|||
expect(2);
|
||||
stop();
|
||||
jQuery.getJSON(url("data/json.php"), function(json) {
|
||||
equals( json.data.lang, 'en', 'Check JSON: lang' );
|
||||
equals( json.data.length, 25, 'Check JSON: length' );
|
||||
if (json && json.data) {
|
||||
equals( json.data.lang, 'en', 'Check JSON: lang' );
|
||||
equals( json.data.length, 25, 'Check JSON: length' );
|
||||
}
|
||||
start();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue