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

Conversation

SalvoDiFede
Copy link

Settings:
settings.usePost: Request type (GET or POST),
settings.useJsonP: request format (JSON or JSONP),
settings.addHeaders: request headers ({Header_Name_One: 'Header Value One'});

bridge.requestPage:
ajax request with type, datatype and headers

Settings:
settings.usePost: Request type (GET or POST),
settings.useJsonP: request format (JSON or JSONP),
settings.addHeaders: request headers ({Header_Name_One: 'Header Value One'});

bridge.requestPage:
ajax request with type, datatype and headers
@iSimonWeb
Copy link
Owner

Hi there Salvo, first of all, thank you for your pull request.
I lke the settings you want to add, here are my considerations and questions:

  • settings.usePost, I've changed my mind about requesting the page via POST, since yesterday a friend of mine have made me think that it's totally wrong for who follow the RESTful approach on backend development.
  • settings.useJsonP, why would be useful to request a response in jsonp? To bypass the domain restriction of XHR requests?
  • settings.addHeaders, just found that jQuery automatically add the header "X-Requested-With:"XMLHttpRequest"" and this is useful to recognize a jBridge page request. That setting will be surely added.

@SalvoDiFede
Copy link
Author

Great Simon, thanks for reply.
settings.useJsonP: yes, jsonP is used for mobile requests, it's usefull in mobile contexts like phonegap, web application wrappers and so on...
settings.usePost: in my opinion, RESTful approach will be fine if you use different endpoint (html, json, partial page request, full page request, and so on), otherwhise you need to set request settings, in any way, then post would be a valid alternative to get with querystrings (afaik)

@iSimonWeb
Copy link
Owner

0647c42

Here's the commit made in response to this issue. Tell me if the code match what you suggested.

@SalvoDiFede
Copy link
Author

Just one effort: requesting only with GET, in respect of REST architecture prospective, there's a problem with JSONP: it works because it is a hack that doesn't use AJAX, it does NOT use a XMLHttpRequest at any point to send the data (that is how it gets around the Same Origin Policy); then it would be usefull to mantain a GET/POST switch, in case backend endpoints cant or want process custom additional headers.

@iSimonWeb
Copy link
Owner

Actually I don't think that jBridge needs to request JSONPs. All that it does by now is retrieving pages and to accomplish that, in a REST architecture, the client have to make a GET request (http://en.wikipedia.org/wiki/Representational_state_transfer#Applied_to_Web_Services).
If you need to call a function on the client after the JSON has been retrieved, there are the two setup functions: onLoad, onUnload.
Finally, why a site could need to load an external page as it is "internal"? The external page MUST be in a jBridge site, otherwise it will never load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants