2

I had create .asmx webservice in asp.net projects. my doubts that is this able to use this webservice in sharepoint project?

suppose this is my code

source: function (request, response) {
                $.ajax({
                    url: "http://localhost:54946/VishalSir/UserName.asmx/FetchEmailList?callback=",
                    data: "{ 'mail': '" + request.term + "' }",
                    dataType: "json",
                    type: "POST",
                    crossDomain: true,
                    contentType: "application/json; charset=utf-8",
                    dataFilter: function (data) { return data; },
                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                value: item.Email
                            }
                        }))
                    },

its works in .net project but i have taken Add Service references in sharepoint projects use this script but its not work.. pl give me direction?

3
  • Just for clarity, this is jQuery running on the client, right? Commented Nov 26, 2011 at 9:12
  • yep..i had fetch data using ajax with json type..its work in normal localhost but not work in sharepoint webapplication. Commented Nov 26, 2011 at 9:19
  • Sorry, I can't see why this code would behave differently in the context of a SharePoint application, since it is client-side code calling your web service. If you tell us what you mean by "does not work" someone may recognize the problem, otherwise I'm not sure we can help you with the information given. Commented Nov 26, 2011 at 10:01

1 Answer 1

3

Yes, you can use web services from within SharePoint. Since you are in this case using jQuery and will likely go from one domain (URL) to another (that is cross domain), you cannot use JSON as it is, but instead have to rely on JSONP.

I've written an example of usage in a post, where the SharePoint site is hosted in Office 365/SharePoint Online and the service is hosted in Azure. Check out: http://www.wictorwilen.se/Post/SharePoint-Online-and-External-Data-using-JSONP.aspx

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.