Este ejemplo asume que existe un webservice llamado wsX que retorna el siguiente string:
{ 'datos': [ {'nombre': 'Juan', 'direccion': 'Colonia 1212'}, {'nombre': 'Pedro', 'direccion': 'Mercedes 1111'} ] }
jQuery.ajax({
type: "POST",
url: http://X14/wsX/wsX.asmx/HelloWorld,
data: "{}",
contentType:"text",
dataType:"text",
cache: false,
success: function(response) {
var v = getJSON(response);
alert("Resultado: " + v.datos[0].nombre);
}
});
function getJSON(data)
{
var s;
s = data.substring(data.indexOf("{"));
s = s.substring(0, s.lastIndexOf("}") + 1);
return eval('(' + s + ')');
}
No hay comentarios:
Publicar un comentario