איך לקבל רשימה (handler) ב Ajax
שלום חברים,
אני פונה לhandler על מנת לקבל רשימה של "פירות" (לצורך הדוגמא).
בAjax אני לא מצליח לקבל אותם
יש לי handler אשר מחזיר List<string>
List<string> lstfruits = new List<string>(); lstfruits.Add("orange"); lstfruits.Add("apple"); context.Response.Write(lstfruits); }
כאשר אני מנסה לברל ב AJAX לא מצליח לקבל את האייטמים
async: false,
contentType: 'application/json',
success: function (Data) { console.log(Data); // for (var i = 0; i < lstData.length; i++) { // console.log(lstData); // } $('#test').append("<option value='saab'>Saab</option>"); } });
מה שאני מקבל זה : System.Collections.Generic.List`1[System.String].
איך אני עושה כדי לקבל את האיטמים ולהכניס ל DropDown
שלום חברים,
אני פונה לhandler על מנת לקבל רשימה של "פירות" (לצורך הדוגמא).
בAjax אני לא מצליח לקבל אותם
יש לי handler אשר מחזיר List<string>
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "application/text";List<string> lstfruits = new List<string>(); lstfruits.Add("orange"); lstfruits.Add("apple"); context.Response.Write(lstfruits); }
כאשר אני מנסה לברל ב AJAX לא מצליח לקבל את האייטמים
$.ajax({
url: "http://localhost:26876/Test2/Handler.ashx",async: false,
contentType: 'application/json',
success: function (Data) { console.log(Data); // for (var i = 0; i < lstData.length; i++) { // console.log(lstData); // } $('#test').append("<option value='saab'>Saab</option>"); } });
מה שאני מקבל זה : System.Collections.Generic.List`1[System.String].
איך אני עושה כדי לקבל את האיטמים ולהכניס ל DropDown