I have a jsp page, in which i have two buttons. Start and Stop buttons. When i click on start button calling one jquery, ajax function. But its getting error message.
Please check the code once
//$.support.cors = true;
$(document).ready(function() {
jQuery.support.cors = true;
url = "http://119.81.26.42/api/order";
$("#start").click(function(e) {
e.preventDefault();
alert("jghjghjghj");
var formData = {
"GUID": "66f1a5ce-3f01-49c3-b825-e0a538ee4fb2",
"Side": "SELL",
"Currency": "USD",
"Metal": "AU",
"Qty": 0.005,
"SHA1": "54745c22ac71adbf282a88c698322f26879124d1"
}
// var formData = $("#data").serialize();
$.ajax({
url: url,
data: formData,
dataType: "json",
type: "POST",
crossDomain: true,
beforeSend: function(req) {
req.setRequestHeader("Access-Control-Allow-Origin:", "*"),
req.setRequestHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS"),
req.setRequestHeader("Access-Control-Allow-Headers", "X-ACCESS_TOKEN, Access-Control-Allow-Origin, Authorization, Origin, x-requested-with, Content-Type, Content-Range, Content-Disposition, Content-Description")
},
success: function(data) {
alert(data);
},
error: function(jqxhr, status, errorMsg) {
alert(status + ": :::::::::===" + errorMsg);
}
});
});
});
table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<title>Trade Response</title>
</head>
<body>
<form>
<button name="button" id="start">Start</button>
<button name="button" style="margin-left: 294px;" id="stop">Stop</button>
<input type="text" name="data" value="" id="data" style="display: none;">
<br>
<br>
</form>
</body>
</html>
