What I am doing is, i am getting data from server side using mvc
. The data is properly coming in return part.
But when I m debugging in the client side, I am only getting the parameter value as [
.
Below is the JSON response which I am getting.
[{"VENDORNAME":"ABC","VENDORCODE":"1234"},{"VENDORNAME":"Abc test","VENDORCODE":"233311"},{"VENDORNAME":"ABC 2","VENDORCODE":"12345"}]
But when I check in the client I get it only [ in the parameter.
Below is that code
getValue: function (element) {
return {
label: element.VENDORNAME,
value: element.VENDORCODE
};
},
in element
i only get as [
Please suggest where I am wrong
update
Here is the full code
var autocompleteOptions = {
url: function (phrase) {
return AppConfig.PrefixURL + 'App/GetVendorData';
},
getValue: function () {
return {
label: element.VENDORNAME,
value: element.VENDORCODE
};
},
ajaxSettings: {
dataType: "json",
method: "POST",
data: {
dataType: "json",
}
},
preparePostData: function (data) {
data.phrase = $("#txtAssignVendor").val();
return data;
},
requestDelay: 400
};
And reference link below
http://easyautocomplete.com/examples#examples-ddg
Server code
[HttpPost]
public JsonResult GetVendorData(string phrase)
{
string strJsonData = "";
try
{
Assignment ObjSAPAssign = new Assignment();
DataTable dt = ObjSAPAssign.GetVendorList(phrase);
strJsonData = JsonConvert.SerializeObject(dt, Formatting.None);
}
catch (Exception ex)
{
ApplicationLog.Error("Error", "GetVendorData", ex.Message);
ErrorLog.HandleErrorLog("", "", "GetVendorData", ex.Message);
}
return Json(strJsonData);
}