When you do work like this, you have to test all the JSON values first using a JSON validator,
1. So you test all your input first in the jQuery
2. test the web service, make sure it return a JSON String or autocomplete values
3. Test your Jquery ResponseText, to make sure the data arrived intact, you may have to encode the strings, and decode them in Jquery
var firstName = document.getElementById('name').value;
var jsonData = "{'username':'" + firstName + "'}";
alert(jsonData);
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "InsertPage.aspx/GetAutoCompleteData",
data: jsonData,
dataType: "json",
error: function (xhr, status, error) {
alert(xhr.responseText);
},
success: function(responseText) {
alert(responseText.d)
var objB = jQuery.parseJSON(responseText.d);
},
});
The web service has to return a valid JSON string back to the JQuery, so you debug the web service, and test the string before sending it back to Jquery. I can't help you with the web service, I would of wrote it different, and just hand build my return values, so I have more control over the process.
JSON Validator
http://jsonlint.com/[
^]