Permalink
Browse files

dj

  • Loading branch information...
1 parent a1a8849 commit 709140a66843d1ac0198313d8debd56540694f09 DalSoft committed Sep 24, 2011
Showing with 24 additions and 8 deletions.
  1. +1 −1 JsHarness/scripts-test/jquery.http.js
  2. +23 −7 JsHarness/scripts/jquery.http.js
@@ -1,6 +1,6 @@
$(function () {
- jg.http.get("https://api.justgiving.com/ea902521/v1/fundraising/pages/justgiving?format=json", function (data) { alert(data.pageId); });
+ jg.http.get({ url: "https://api.justgiving.com/ea902521/v1/fundraising/pages/justgiving?format=json", overrideCallback: function (data) { alert(data.pageId); } });
module("jquery.http.js");
@@ -1,25 +1,41 @@
(function ($) {
+
+ $.ajaxSetup({
+ dataType: 'jsonp'
+ });
+
+ function success(settings, data) {
+ if (settings.overrideCallback)
+ settings.overrideCallback(data);
+ else
+ jg.settings().onResponse(data);
+ }
+
$.extend({
http: {
get: function (settings) {
var ajax = {
url: settings.url,
+ success: function (data) { success(settings, data); }
+ };
+ $.ajax(ajax);
+
+ },
+ put: function (settings) {
+ var ajax = {
+ url: settings.url,
dataType: 'jsonp',
+ data: settings.data,
success: function (data) {
if (settings.overrideCallback)
settings.overrideCallback(data);
else
- jg.settings().
+ jg.settings().onResponse(data);
}
};
- $.ajax(settings);
-
- },
- put: function () {
-
- return "PUT";
+ $.ajax(ajax);
},
head: function () {
return "HEAD";

0 comments on commit 709140a

Please sign in to comment.