Wednesday 15 June 2011

authentication - deployd authentification using jquery ajax -


I have deployed my Debian 7.0.0 64 bit, I have also installed it successfully, I have made something Dashboard deployed in collection and user archive, then how to connect and query tables using the user guide, I select jquery ajax to log in to deploy from my local host site and login after success Some day I try to receive / post, but in no way deprived me of the permission to deploy. I have made the name of the collection people, and then I wrote this code in GET, Post, Pt Event: < Pre> Cancel (me, "you are not logged in", 401);

By using this AJAX code, I try to login and post new people's data:

  $ (document) .ready (Function () {/ * Create a query for the username and password for the login * / var request = new object; request.username = 'myusername'; request.password = 'mypassword'; Submit adapter = "http: // Myipaddress: myport / users / login "$$ Ajax ({type:" post ", url: submitaddress, data: request, cache: wrong, success: work (data) {var returndata = eval (data); / * login success After people's data Try to post / if (Returndata) {var request2 = new object; request2.name = 'People Name'; submitaddress2 = "http: // myipaddress: myport / people"; $ .ajax ({type: "post ", Url: submit submission 2, data: request2, cache: wrong, success: function () {}}}}}}};   

}) < P> login process success, this is the return session id and my user id, but after login login and i try to post to people, it is back "you are not logged", someone can help meLand, which is the correct way to log can be used G website (cross domain from other websites)?

Because you are sending a cross domain request (CORS), cookies automatically with HTTP request To enable it in jQuery, you must set the credential property of xhrFileds with the reality; Example below:

  / * Create a query for the username and password for the login * / var request = {}; Request.username = 'MyUsername'; Request.password = 'MyPassword'; Submitaddress = "http: // myaddress: myport / users / login"; $ AJAX ({type: "post", url: deposit address, data: request, cache: wrong, exerfield: {with credit: true}, success: work (data) {console.log}; / * After logging in successfully try to post people * / if (data.id) {var request2 = {}} request2.name = 'people name'; submitaddress2 = "http: // myaddress: myport / users / Me "; $. ({Type:" GET ", url: submitaddress2, cache: true, xhrFields: {with credentials: true}, success: function (data) {console.log (data);}})}} }});   

See for more information.

No comments:

Post a Comment