I\'ve checked a few similar questions, but none of the answers seem to fit (or dumb it down enough for me). So, I have a really simple WebAPI to check if user with an email
You can create an object in your JavaScript:
var myData= {
Email: "me@email.com"
};
This creates an object, matching the object expected by the controller.
You then set the Ajax call to pass this as the data property:
$.ajax({
url: "/api/User/",
type: "GET",
data: myData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
if (data == true) {
// notify user that email exists
}
else {
// not taken
}
}
});
I like this approach, as you can then add more properties as required. However, if you are only passing the email address, you might want to just pass a string.