Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
    
Just for clarity, this is jQuery running on the client, right? –  SPDoctor Nov 26 '11 at 9:12
    
yep..i had fetch data using ajax with json type..its work in normal localhost but not work in sharepoint webapplication. –  jigs Nov 26 '11 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. –  SPDoctor Nov 26 '11 at 10:01

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
thanks @wictor. –  jigs Nov 28 '11 at 5:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.