on 02-26-2016 6:01 PM
Hi,
Should we use url parameters to send data to service for a POST call or send the data as body in the request?
What is the right way to do in terms of standards and security?
Regards,
Pranjal
Hi Pranjal,
Sending parameters via url would be a huge task especially when you have a huge amount of data. Sending the data as body and then consuming it in XSJS would be the right way of doing this.(i guess!)
Regards,
Pratik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
GET will read the data. you can use POST for sending it. see the below snippet:
var token = XMLHttpRequest.getResponseHeader('X-CSRF-Token');
$.ajax({
url: <target_url>,
type: "POST",
beforeSend: function(xhr)
{
xhr.setRequestHeader("X-CSRF-Token", token);
},
processData :false,
contentType: false,
POST_DATA:data,
success:function(){
alert("sucess in post");
},
error:function(){
alert("fail");
}
})
here, "data" would be anything that you have read, maybe a JSON being read from a GET.
so, initially you would read the data from a source URL and get it in say JSON format and then using POST, you can send it to the target URL.
Hope this helps!
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.