ajax - How can I post data as form data instead of a request payload? -
In the code below, AngularJS calls the How can I submit AngularJS to XSR as form data instead of a request payload? The following line must be added to the $ http object that has been passed: and passed data should be changed URL-encoded string: So you have something like this: to: $ http method URL, and the XSRF object Submits as "request payload" (as described in the Chrome Debugger Network tab) JQuery
$. The Ajax method calls the same call, but submits XSR as "form data".
var url = 'http://somewhere.com/'; Var xsrf = {fkey: 'xsrf key'}; $ Http ({method: 'POST', url: url, data: xsrf}) Success (work () {}); $ .ajax ({type: 'post', url: url, data: xsrf, data type: 'jason', success: function () {}});
header: {'content-type': 'application / x-www-form-urlencoded'}
& gt; $ .arm ({fkey: "key"}) 'fkey = key'
$ http ({method : 'Post', url: url, data: $ .human ({fkey: "key"}), header: {'content-type': 'application / x-www-form-urlencoded'}})
Comments
Post a Comment