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

SharePoint 2010 Questions.

I am trying to create an auto suggesting text-box with multiple values in a SharePoint web part. i am using j query and SharePoint list web services to do it. I am just learning to do these stuffs but not getting a result. Any help much appreciated.

Following is the code. i am creating an alert to see if i get any data but it alerts a blank dialog

this is my latest code

var restServiceAddress = "/_vti_bin/ListData.svc/";
var listName = "Topics";
function split(val) {
    return val.split(/,\s*/);
}

function extractLast(term) {
    return split(term).pop();
}  

  $(document).ready(function () {


    $('#<%=input_title.ClientID%>').autocomplete({

        source: function (request, response) {
            $.ajax({
                type: "POST",
                contentType: "application/json;charset=utf-8",
                url: "" + restServiceAddress + listName,
                data: "{'Title':'" + request.term + "'}",
                dataType: "json",
                success: function (data) {
                    response($.map(data.d, function (item) {
                        return item.Title;

                    }))
                }
            });
        },
        focus: function () {
            return false;

        },
        select: function (event, ui) {
            var terms = split(this.value);
            terms.pop();
            terms.push(ui.item.value);
            terms.push("");
            this.value = terms.join(", ");
            return false;
        },
        minlength: 1

    });
});

share|improve this question

2 Answers 2

In your code, you are mixing up two different types of Web services: the legacy ones (lists.asmx) and the REST services that come with SharePoint 2013.

Assuming that you are working with SharePoint 2013, the url for your ajax call should look like this:

http://<site url>https://waybackassets.bk21.net/lists/getbytitle('<list title>')/items?$filter=startswith...
share|improve this answer
    
i am working with SharePoint 2010. This is the first time i am trying to do this. Is the URL correct for SharePoint 2010. –  user388969 Jun 27 at 13:24
    
For SP 2010, see @PirateEric's answer. For such questions, it's important to tell which version of SharePoint you are working with. –  Christophe Jun 27 at 17:41
    
Updated the code with my latest work, the latest codes gives me a null error. I am not able to send the starts with character in the URl how do i do that... –  user388969 Jun 27 at 18:35

If you are trying to use REST, your URL is wrong and is why it isn't working. It needs to be http://mysite.com/_vti_bin/listdata.svc/mylist

If you are trying to use the SOAP based web services, then that is not right either. I'd suggest using a library like SPServices to help interact with the SOAP web services.

share|improve this answer
    
i added the SPServices but everytime i define a spservices object it says object not defined. I am not sure why it is not recognized SPServices as object. I tried this var thisSite = $().SPServices.SPGetCurrentSite(); It says cannot find SPServices. –  user388969 Jun 27 at 13:27
    
Then this means you don't have your file references right. jQuery needs to load first, then SPServices, then your script. –  PirateEric Jun 27 at 14:27

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.