I wonder what I'm doing wrong, already tested several tutorials without success, the data comes without the formatting that is in the script, in this example I have in my Controller,
public JsonResult GetDados()
{
List<Object> resultado = new List<object>();
resultado.Add(new
{
Nome = "studying Json",
URL = "https://stackoverflow.com/"
});
resultado.Add(new
{
Nome = "Json ",
URL = "https://stackoverflow.com/"
});
resultado.Add(new
{
Nome = "Mr. Json",
URL = https://stackoverflow.com/"
});
return Json(resultado, JsonRequestBehavior.AllowGet);
}
View :
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.1.js"></script>
<script>
$(function () {
$.ajax({
dataType: "json",
type: "GET",
url: "/Home/GetDados",
success: function (dados) {
$(dados).each(function (i) {
document.writeln("<p>Nome: " + dados[i].Nome + " | URL: " + dados[i].URL + "</p>")
});
}
});
});
</script>
The correct display of the result would be:
Nome: studying Json | Url: https://stackoverflow.com/
Nome: Json | Url: https://stackoverflow.com/
Nome: Mr. Json | Url: https://stackoverflow.com/
I have this result see that in document.writeln script, I'm writing the return json with a
, the image the result is not the same.

dados[i].URLvalue needs to be in a<a>elementdocument.writeafter page loads...it will wipe whole page out