Externalizar funciones JavaScript
Publicado por Aristoteles (3 intervenciones) el 26/05/2014 11:21:33
Hola buenos días, a ver si alguno me podéis echar una mano...
Yo tengo esto:
Lo que quisiera es externalizar la funcion "function (datos)" para luego llamarla desde el getJSON...¿es posible? Y si lo es...¿podéis darme alguna directriz?
Gracias de antemano!!
Yo tengo esto:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<html lang="es">
<head>
<script type="text/javascript">
function checkProcess(){
alert("pulsado boton Check");
$.getJSON('/',
{ operation: 'LA OPERACION CORRESPONDIENTE' },
function(datos) {
var texto="";
texto=JSON.stringify(datos);
if (datos.resultado=="Ok") { alert ("Correcto");
$('#huecoImagen').html('LA URL CORRESPONDIENTE');
$('div').text(texto);
}
else {alert ("Incorrecto");};
}
)
.fail(function() {
alert( "error en el CHECK" );
});
</script>
</head>
<body>
<button onclick="checkProcess()">Check</button>
<div>Aqui se va a mostrar el JSON</div>
<p id='huecoImagen'>Aqui se deberia cargar la imagen</p>
</body>
</html>
Lo que quisiera es externalizar la funcion "function (datos)" para luego llamarla desde el getJSON...¿es posible? Y si lo es...¿podéis darme alguna directriz?
Gracias de antemano!!

Valora esta pregunta


0