I'm testing the basics for exchanging rest messages between a asp.net mvc site and a WCF 3.5 service. The service is built using the template found in the WCF REST Starter Kit found on codeplex. I would like to exchange json messages using jquery. The REST Singleton service is working properly and it also provide examples of all the possible calling adding the help parameter ad the end of the uri. I arrive to perform GET requests with the built in jquery $.getJSON. I have problems doing the PUT (for updating values) and POST.
$.ajax({
type: "PUT",
dataType: "json",
url: "http://localhost:1045/Service.svc/?format=json",
data: '{"Value":testvalue}'
});
What is the best approach for this? Is it possible not to use Ms. Ajax at all and is it correct to bypass it?
Also make sure you have your contentType set correctly in your ajax call.
contentType: "application/json"
The JQuery default is
contentType: "application/x-www-form-urlencoded"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With