jQuery's ajax()
sends the data with Content-type: x-www-form-urlencoded
.
Angular's $http
sends the data with Content-type: application/json
Your server obviously expects JSON, but you set up the $.ajax()
call incorrectly for that.
According to the docs:
- The
method
property doesn't seem to exist. - The
type
property is supposed to determine the type of the request (e.g. 'GET', 'POST', etc.). - In order to change the default content-type to
application/json
you can use thecontentType
property.
I have not tried it myself, but something like this should work:
$.ajax({
type: 'POST',
url: rootUrl + '/api/Address/SearchAddress',
async: false,
data: searchDetail,
contentType: 'application/json; charset=utf-8'
});