Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jQuery.Bridge.js #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions jQuery.Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
// @type: CSS selector
// Matches anchors to be AJAXified
internalAnchors: 'a[href^="/"]',
// define ajax request type
usePost: true,
// define ajax request format (if false -> json)
useJsonP: false,
// define additional headers on ajax request
addHeaders: null,
//
onUnload: bridge.bypass,
//
Expand Down Expand Up @@ -265,7 +271,25 @@
bridge.requestPage = function() {
bridge.log('Requesting page: ' + window.location);

return $.post(window.location);
var ajaxRequest = {
url: window.location,
type: settings.usePost ? 'post' : 'get',
dataType: settings.useJsonP ? 'jsonp': 'json',
success: function (data) {
// Log success ajax request
bridge.log('Successfull page retrieve');
}
};

//header example:
//Header_Name_One: 'Header Value One', //If your header name has spaces or any other char not appropriate
//"Header Name Two": 'Header Value Two' //for object property name, use quoted notation shown in second
if (settings.addHeaders){
ajaxRequest.headers = settings.addHeaders;
}

//send via get or post with additional headers in json or jsonp format
return $.ajax(ajaxRequest);
};

/**
Expand Down Expand Up @@ -410,4 +434,4 @@

return bridge;
};
})(jQuery);
})(jQuery);