Permalink
Browse files

modify test so it runs locally

  • Loading branch information...
madrobby committed Dec 22, 2010
1 parent 0393df0 commit faa2ebd297ba24653e2bcf6722d96fb8cdbcf7a2
Showing with 7 additions and 7 deletions.
  1. +4 −5 src/ajax.js
  2. +2 −2 test/ajax.html
  3. +1 −0 test/fixtures/jsonp.js
View
@@ -7,19 +7,18 @@
$.ajaxJSONP = function(options){
var jsonpString;
jsonpString = 'jsonp' + ++jsonpID;
- window[jsonpString] = function(j){ options.success(j) }
+ window[jsonpString] = options.success;
var script = document.createElement('script');
- $(script).attr({ src: options.url.replace(/callback=\?/, 'callback=' + jsonpString), type: 'text/javascript' });
+ $(script).attr({ src: options.url.replace(/callback=\?/, 'callback=' + jsonpString) });
$('head').append(script);
};
$.ajax = function(options){
// { type, url, data, success, dataType, contentType }
options = options || {};
- if (options.url && /callback=\?/.test(options.url)) {
- return $.ajaxJSONP(options)
- }
+ if (options.url && /callback=\?/.test(options.url))
+ return $.ajaxJSONP(options);
var data = options.data,
callback = options.success || empty,
View
@@ -65,9 +65,9 @@ <h1>Zepto Ajax unit tests</h1>
testAjaxGetJSONP: function(t){
t.pause();
- $.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=?', function(data){
+ $.getJSON('fixtures/jsonp.js?jsoncallback=?&timestamp='+(+new Date), function(data){
t.resume(function(){
- this.assertEqual(data.items.length, 20);
+ this.assertEqual(data.items.length, 0);
});
});
},
View
@@ -0,0 +1 @@
+jsonp1({"items":[]})

0 comments on commit faa2ebd

Please sign in to comment.