Retornar un valor desde una funcion con llamado a jQuery.Ajax

int a;
String j;
void main()
{
   int j;
}


function existeRolUsuario(usuario, rol)
{
var url_ws
url_ws = "http://" + window.self.location.hostname + "/wsPRUEBA/Seguridad.asmx/ExisteRolUsuario";


var response = jQuery.ajax({
type: "POST",
timeout: 5000,
url: url_ws,
data: "{'usuario': '" + usuario + "', 'rol': '" + rol + "'}",
contentType:"application/json; charset=utf-8",
dataType:"json",
async: false,
cache: false,
success: function(response) {

},
error: function(xhr, ajaxOptions, thrownError) {
alert("error!");
}
}).responseText;

var j = eval('(' + response + ')');
var v = getJSON(j);

if (v.datos[0].existe == "true")
return true;
else
return false;
}

---------------------------------------------------------------------------------------
Otra forma:


function InvocarAjax()
{
rnd = '&random=' + Math.floor(Math.random()*9999999999);

jQuery.ajax({
data: "parametro1=valor1&parametro2=valor2" + rnd,
type: "GET",
dataType: "json",
url: "ajax.php",
success: function(response){
procesarRespuesta(response);
}
});

}

function procesarRespuesta(response)
{
alert("Respuesta: " + response.prueba);
}

No hay comentarios:

Publicar un comentario