I can not throw the result of the ajax query inside a table. The result is an array (result = Object {BrowseAllCategoriesResult: Array (6)})
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form id="form1">
<div class="jumbotron">
<input type="text" id="codUser"/>
<button onclick="ConsUsuario(); return false;">Consulta Usuario</button>
</div>
<div><table id="datagrid"></table></div>
</form>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script><scripttype="text/javascript">
function ConsUsuario(){
$.ajax({
type: "GET",
url: "http://food-fast-com.web27.redehost.net/CategoriaService.svc/ConsultarTodosCategorias",
contentType: "application/json",
dataType: "json",
success: function (result) {//result = Object {ConsultarTodosCategoriasResult: Array(6)}
debugger;
var tabela = $("#datagrid");
var rows = "";
tabela.find("tbody td").remove();
var myData = ConsultarTodosCategoriasResult;
for (var i = 0; i < myData.length; i++) {
var obj = myData[i];
rows += "<tr>";
rows += " <td>" + result.ConsultarTodosCategoriasResult.Descricao + "</td>";
rows += "</tr>";
}
tabela.html('<tbody>' + rows + '</tbody>');
}
});
}
</script>
When assigning the result to a variable (var myData = QueryAllCategoriesResult;) it gives the following error: Uncaught ReferenceError: QueryAllCategoriesResult is not defined