Friday, May 18, 2012 1:41 PM
I have a custom Sharepoint webservice returning array of obejcts. But when I call this webservice from JQuery it alwayes return XML. When I set contentType as "application/json" the web service throws error saying "Unsupported media type".
I want array of objects back. I have set [ScriptMethod(ResponseFormat = ResponseFormat.Json)] above my webmethod.
One more thing, even if the webservice is getting executed successfully, always AjaxFailed() function is getting executed. The success function is never getting executed.
so two problems
1. How to return JSON ?
2. Why alwayes Ajax failed function is getting executed even if status says OK. ?
Code snippet is below.
Thanks much in advance.
Friday, May 18, 2012 5:18 PM
Hi!Did you try to specify content-type in request?
MVP Office Development, MCP, MCTS SharePoint 2010 Development
Friday, May 18, 2012 5:49 PMModerator
In the var wsUrl = "_vti_bin/DisclosureWebService.asmx "; line
shouldn't you append the name of your webmethod ?
var wsUrl = "_vti_bin/DisclosureWebService.asmx/<name_of_method> ";
Saturday, May 19, 2012 1:26 AM
This link maybe helpful.
Tuesday, May 22, 2012 5:30 PM
Yes I Did. If I specify application/json , the function throws error saying "Unsupported media type."
Tuesday, May 22, 2012 5:32 PM
Yes I did add a webmethod name. Also the SOAP request has details. So even if I dont mention the webmethod name, the SOAP request takes care of that.
Tuesday, May 29, 2012 4:32 PMI removed the SoapREquest parameter and it started returning the Json object.
- Marked As Answer by MKKi Tuesday, May 29, 2012 4:32 PM