Cannot override data in ajax:beforeSend Event
See original GitHub issueI try to send some data with a post ajax request like this and in the server side i dont receive the data (but i do see the value in firebug)
$('a[data-with], a[data-submit]').live('ajax:beforeSend', function(event, xhr, settings) {
settings.data = "name=John&time=2pm";
});
but if im doing like this it s working
$('a[data-with], a[data-submit]').live('ajax:beforeSend', function(event, xhr, settings) {
settings.url += "?name=John&time=2pm";
});
My route is configured as a POST method
resources :categories do
collection do
post :addcategory
end
end
What im doing wrong ?
Issue Analytics
- State:
- Created 12 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
using ajax beforeSend to modify data - Stack Overflow
As you can see, the setting processData should to be false. So it can be setted when you do request in $.ajax() or...
Read more >jQuery.ajax() | jQuery API Documentation
The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the...
Read more >Working with JavaScript in Rails - Ruby on Rails Guides
This guide covers the built-in Ajax/JavaScript functionality of Rails (and more); it will enable you to create rich and dynamic Ajax applications with...
Read more >Ajax/jQuery.getJSON Simple Example - SitePoint
Learn how to use jQuery's getJSON helper to load JSON-encoded data from a server using a GET HTTP request.
Read more >JQueryAjaxSettings | typescript - v3.7.7
ajax (), then it is always sent to the server (even if no data is sent). As of jQuery 1.6 you can pass...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oki im pretty satisfied with the solution to use the ajax:before like i did.
But i m still convinced there is an issue with this line in jquery-ujs.js(line 115)
and we need at on point to clean the data store in the current element by doing
if not if you change the data after the first submission, it will continue to send the same value.
to get working this is what i was doing
Hey @JangoSteve, I tried to do this with forms, but after reading the code a little bit more closely, it seems that
data-params
was only forrails.inputChangeSelector
and non-forms. Did I read it right?How would you go about appending data to a form before sending it out? I have one already in a long serialized string that I get from another plugin, and would simply like to append it to the data of the form.
Thanks!