I am trying to make a html which contains a submit button , when clicking on button i want to make a post request to a webserver. What i want to send :
curl -X GET http://192.168.2.253:8080/server/getReportData/ -d '{"project":"voda1","startDate":"1-1-2016","month":"0","endDate":"10-1-2016","simType":"0","roming":"0","latitute":"","longitude":"","radius":"","Peak":"0","kpi":[201],"name":"wavenet"}' -H "Content-Type: application/json
what actully webserver got :
http://192.168.2.253:8080/getReportData/%20-d%20%7B%22project%22%3A%22voda1%22%2C%22startDate%22%3A%22%22%2C%22month%22%3A%22%22%2C%22endDate%22%3A%22%22%2C%22simType%22%3A%220%22%2C%22roming%22%3A%220%22%2C%22latitute%22%3A%2220.077728%22%2C%22longitude%22%3A%2221.07728%22%2C%22radius%22%3A%2212%22%2C%22Peak%22%3A%220%22%2C%22kpi%22%3A%5B%22201%22%2C%22203%22%2C%22303%22%5D%2C%22name%22%3A%22wavenet%22%7D
How to do it correctly.
Below Is my javascript for demo
JSONTest = function() {
var resultDiv = $("#resultDivContainer");
var data1 = {"user" : "mushir"};
alert(data1);
$.ajax({
url: "http://192.168.2.253:8080/server/getReportData/?",
method:'GET',
data: JSON.stringify(data1),
//data: { apiKey: "23462", method: "example", ip: "208.74.35.5" },
dataType: "json",
contentType: 'application/json',
success: function (result) {
switch (result) {
case true:
processResponse(result);
alert(result);
break;
default:
resultDiv.html(result);
}
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
};