javascript - Rails4 - How to receive and send JSON data securely through Ajax and store it? -
javascript - Rails4 - How to receive and send JSON data securely through Ajax and store it? -
i have page(like https://www.helloabc.com/han.html) loaded within iframe on app of different domain. added next enable loading page in iframe remove error("refused display document because display forbidden x-frame-options").
config.action_dispatch.default_headers['x-frame-options'] = "allow-from https://xyz.com"
the iframe page sends info through ajax json page follows .
$.ajax({ url: 'https://www.helloabc.com/hello', type: 'post', datatype: 'json', data: { "url" : hjurl, "data" : senddatavar }, success: function(a){ console.log("success"); console.log(a.message); }, error: function(request, status, error) { console.log("error"); } });
i receive 200 ok in iframe page.
heroku[router]: at=info method=post path="/hello" host=www.helloabc.com request_id=ac3ed869-75cc-484f-94ea-65ea2fccbb9e fwd="117.203.154.1" dyno=web.1 connect=3ms service=26ms status=200 bytes=900 app[web.1]: started post "/hello" 117.203.154.1 @ 2014-11-07 16:45:29 +0000 app[web.1]: processing homepagecontroller#hellojson json app[web.1]: parameters: {"url"=>"https://abc.yupp.com/hs/_/krki5gea", "data"=>{"0"=>{"id"=>"937bacaeb0f928", "person"=>{"id"=>"1984762436", "dname"=>"zzzzz", "image"=>{"url"=>"https://sbc/photo.jpg"}}, }}} app[web.1]: completed 200 ok in 2ms (views: 0.4ms | activerecord: 0.0ms)
i new rails. don't know how grab info , store it. , dont know how right way. can please share best practice send info through ajax securely , store it?
i used params in next controller info , save in table
def hellojson m = haout.new m.url = params["url"] m.image = params["data"]["0"]["person"]["image"]["url"]
then used conditions , based on conditions did m.save , m.update_attributes
it secure if https used
javascript ruby-on-rails ajax json ruby-on-rails-4
Comments
Post a Comment