Вопрос

I am trying to implement the Tag-It jQuery UI plugin ( http://aehlke.github.com/tag-it/ ).

It works great as long as I don't use custom autocomplete. It can show tags, show suggestions from a predefined list, I can remove them ect.. But when I want to make an AJAX call it gives me problems. Bascically, the Tag-It control never shows any results.

Currently my code is:

<script type="text/javascript">
    $(document).ready(function() {
        $("#myabtags").tagit({
            tagSource: function(request, response) {
                $.ajax({
                    type: "POST",
                    url: "Services/ForumServices.asmx/GetTags",
                    dataType: "json",
                    data: { prefixText: request.term, count: 10 },
                    success: function(data) {
                        response(data);
                    }
                });
            },
            removeConfirmation: true

        });
    });
</script>

I can see in Fiddler the request is made as it should, and it returns a perfectly fine result. An example of a result is:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
  <string>acceleration</string>
  <string>aktantmodellen</string>
  <string>ampere</string>
  <string>analyse</string>
  <string>analyseeksempel</string>
  <string>atmosfæren</string>
  <string>best practice</string>
  <string>boganmeldelse</string>
  <string>brændtrekanten</string>
  <string>cellemembran</string>
</ArrayOfString>

So basically I guess there is something I do wrong in the JSON succes call? Or am I totally wrong?

Any ideas? Hints? Something? :)

Это было полезно?

Решение

Looks like the dataType is the issue here..

You returned data seems to be xml and you have

dataType: "json"

Try replacing it with

dataType: "xml"
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top