A Json object doesn't exist in my Json array to storage it

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



A Json object doesn't exist in my Json array to storage it



I got a problem with my Json. I have a list from SQL Server and I do the next step for making the conversion to Json:


var data = JsonConvert.SerializeObject(produList); //produList's my list
var info = Json(data, JsonRequestBehavior.AllowGet);



but when I call to my method in Ajax, I just have a Json array, without an object that storages my array. My Json array shold look some like this:


Object: (3) […, …, …]
0: idProducto: 1, Producto: "IPAD", Precio: 750, Stock: 10
1: idProducto: 2, Producto: "MAC", Precio: 1450, Stock: 2
2: idProducto: 3, Producto: "IPHONE", Precio: 500, Stock: 7



But it looks like this and I don't know why if I'm also doing the Json.parse in my Ajax


(3) […, …, …]
0:idProducto: 1, Producto: "IPAD", Precio: 750, Stock: 10
1:idProducto: 2, Producto: "MAC", Precio: 1450, Stock: 2
2:idProducto: 3, Producto: "IPHONE", Precio: 500, Stock: 7



And I got to run my Json array but I don't have a name for my Json array. This is my Ajax:


function __ajax(url, data)
var ajax = $.ajax(
type: "POST",
data: JSON.stringify(data),
url: url,
contentType: "application/json; charset=utf-8",
dataType: "json"
);
return ajax;



and my JavaScript code:


function listar()
var url = $("#data_productos").data("urlAction");
__ajax(url, "")
.done( function ( info )
var productos = JSON.parse(info);
for (var i in productos)


);



I appreciate all your help!!









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard