I have an HTML form
in my page. On submit of the form, I am trying to send a JSON file (constructed from the html form) with POST
method in a Web Service
which runs on my network:
$('form').on('submit', function (e) {
e.preventDefault();
var formData = {};
formData["productId"] = $('#productId').val(); //<--This the value from the html form
var json = JSON.stringify(formData); //<-- This is the json file that I try to send
$.ajax({
type: 'POST',
method: 'POST',
url: 'http://link_of_web_service',
data: json,
dataType: 'json',
contentType: 'application/json',
success: function (data) {
alert(data);
}
});
});
But, in the console of the Web Service, I am getting this error message:
Unsupported HTTP method 'OPTIONS' was requested from '192.168.0.251:52743'
I can't figure out why the web service interprets the sending method as OPTIONS
and not as POST
that I have set. The json
is not empty, as the console.log(json)
prints
{ "productId":"703156124"}
The Web Service
that I am setting is from Bartender software.