nikku/jquery-bootstrap-scripting

Find a way to interact with the url/headers for ajax loading

Closed this issue · 2 comments

Hi,

it would be great if we could have a simple way to get and modify the urls before ajax loading: sometimes, we want to know on the server-side if the request has been triggered by the plugin or not, and the standard X-Requested-With header is not always good enough/sufficient in complex applications.

For example, we could want to add the "_dialog2=1" parameter on each request (or an equivalent http header) without rewrite the whole loading process .

Thanks!

One would need to provide an extension point for dialog2 users which lets them hook into beforeSend(jqXHR, settings). Unfortunately this would imply rewriting the dialogs load and form submit logic to use plain http://api.jquery.com/jQuery.ajax/ instead of the loaders provided.

I will see if I have time for that in the near future.

Anyway, really interesting issue. Remember I needed something like that myself a few weeks ago.

Had some time to work on the script this weekend.
If you are still interested check out the current master branch of the project (compatible with bootstrap 2.x). I implemented an event dialog2.before-send you can bind to. It receives the XMLHttpRequest to be sent to the server as well as the JQuery ajax settings as arguments. E.g. try out dialog.bind("dialog2.before-send", function(event, xhr, settings) { alert(xhr); }.