javascript - Rails 3: Jquery code breaks when making simple AJAX call, think is a simple mistake -
To update the user registration, in the Registry Registry Controller
I have in my opinion
& lt;% = form_for (@user ,: as = & gt; processing_name ,: url = & gt; registration_path (resource_name) ,: html = & gt; {: method = & gt; : Put: id = & gt; 'shared-form'} ,: remote => true) f | F | & Gt%; & Lt;% = f.check_box: facebook_share% & gt; & Lt;% = f.label: facebook_share ,: class = & gt; 'Submit-Share'% & gt; & Lt;% end% & gt; So ID = "share-form" in this form, I have a URL and the specified method.
When my jacquery form is stored normally, but the database has not been updated with any data:
$ (document) .ready (function () {$ ('Submit-share') (function () {$ ('# share-form'). Submit ();});}); The console reads:
started for POST "/ user" on 127.0.0.1 2014-07-25 13:34:21 +0700 #update as the controller controller HTML parameters by registration: {"UTF8" => "One ????" "Authenticity_token" = & gt; "GrQWqDseCwhlrpNhv8i3hvlL4iwae0U / pp + wSu4iabk =", "user" => {"Facebook_share" = & gt; Select "0"}} User Load (0.5 MMS) "Users". * Select "User" from "users". "Id" = 31 LIMIT 1 cache (0.0 mms) "Users". * Select "1 user" from "user" "users" "id" = 31 LIMIT 1 sql (0.8 mms) (less "user". "Email") = lower (woo @ driv.o ') And select limit 1 SQL (0.1ms) COUNT ("user" id) (*) Select "Authentications" ("Authentications" .user_id = 31) Cache (0.0ms) COUNT ("Authentication". User = 31) from "Authentication" ("Authentication". User = 31) "Authentication" ("Authentication"). Skyuel (0.1 ms) and select "user where" 1 "Users". "= 'Fenznname') and (" user ".id> 31) LIMIT 1 slug load (0.7 ms) Select" Stool. "Where" Stool "(" Stool ".sluggable_id = 31 and" Mal ".sluggable_type = 'user'), select the ID DESC limit 1 cache (0.0ms)" those ". *" Users "WHERE" user "." ID "= 31 LIMIT 1 redirected http: // localhost: 3000 / full 302 found in 361ms When I add this AJAX call to the data updating, submit does not work There is nothing else where I am going wrong ?? And the console does not say anything $ (document) .ready (Function () {$ ('submit-share'). (Function () {$ ('# share-form'). Submit (function () {$ .ajax ({method: this.method, url} : This.action, data: $ ('# share-form'). Sort ()})}};});}); I'm confused , I think this is a simple mistake, thanks a lot.
Some things to try :
Sent from the rail formats prevents random model attributes and is the list of those parameters variable in Rail 3, in this model attr_accessible is set in Rail 4, it is set in the controller through strong_param gem. If you have not set facebook_share to whitelist, it will be snatched silently. Or ...
: remote = & gt; Is there a rail thing where it will take care of Ajax for you unless you include a UAS script to handle the returned goods and to send you the data to make the jacket bits Should not be required. more info . If you have enabled this and some are doing jQuery on top, then there may be some conflicts. Anyway: In fact, coming back through AJAX to get an insight, I recommend that you install and therefore you will not have to break the breakpoint in the controller. Can stop and see what's going on. This is a habit of taking headache with such things :)
Comments
Post a Comment