Reputation: 32321
I am making a Cross Domain AJAX POST Call to my Rest WebService
This is my HTML Code
$(document).on("click", ".submit", function(e) {
var name = $('#name').val();
var mobile = $('#mobile').val();
var email = $('#email').val();
if(name==''||mobile==''||email=='')
{
alert('Please Fill All the Details');
return false;
}
else
{
var information = {
"name": name,
"mobile": mobile,
"email": email
}
var dataaa = JSON.stringify(information);
console.log(dataaa);
$.ajax({
type: 'POST',
url: 'http://192.168.2.46:8080/PostEx/test/testservice',
jsonpCallback: 'jsonCallback',
cache: true,
data: dataaa,
dataType: 'jsonp',
jsonp: false,
success: function (response) {
alert(response);
},
error: function (e) {
$("#divResult").html("WebSerivce unreachable");
}
});
}
});
<body>
<form method="POST">
<div class="required">
Name: <input class="required" type="text" id="name" name="name"> <span class="asterisk_input"> </span> </br>
Phone: <input type="mobile" id="mobile" name="mobile"> <span class="asterisk_input"> </span> </br>
E-mail: <input type="email" id="email" name="email"> <span class="asterisk_input"> </span> </br>
</div>
<input class="submit" type="submit">
</form>
</body>
I am observing under the Browser console
Sorry for the big image i don't know how to crop the picture .
Upvotes: 0
Views: 143
Reputation: 700192
When using JSONP you can't make a POST request.
A JSONP request doesn't use the XMLHTTPRequest object to do the request, it adds a script
tag to the page that makes the request by loading the resource as Javascript. The script
tag doesn't have a means of specifying the method of the request, it's always a GET request.
Upvotes: 2