-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (60 loc) · 2.03 KB
/
script.js
File metadata and controls
67 lines (60 loc) · 2.03 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
$(document).ready(function() {
$("form").submit(function(event) {
$("#formulario").addClass("loading");
$("#formulario").append('<div class="spinner"></div>');
$(".form-group").removeClass("has-error");
$(".help-block").remove();
if ($("input[name=parada]").val() == "Q") {
$("input[name=parada]").val("N2894");
$("#linea option:selected").text("17");
}
var formData = {
parada: $("input[name=parada]").val(),
linea: $("#linea option:selected").text()
};
$.ajax({
type: "POST",
url: "soap.php",
data: formData,
dataType: "json",
encode: true
})
.done(function(data) {
$("#formulario").removeClass("loading");
$(".spinner").remove();
// log data to the console so we can see
console.log(data);
if (data.success) {
if (!data.result.RecuperarProximosArribosResult) {
$("#resultado").append(
'<div class="alert alert-this sharp help-block">' +
"Sin resultados (¿Esta llegando?)" +
"</div>"
);
} else {
$("#resultado").append(
'<div class="alert alert-this sharp help-block">' +
data.result.RecuperarProximosArribosResult.ProximoArribo.arribo +
"</div>"
);
}
} else {
// linea ---------------
if (data.errors.linea) {
$("#linea-group").addClass("has-error"); // add the error class to show red input
$("#linea-group").append(
'<div class="help-block">' + data.errors.linea + "</div>"
); // add the actual error message under our input
}
// parada ---------------
if (data.errors.parada) {
$("#parada-group").addClass("has-error"); // add the error class to show red input
$("#parada-group").append(
'<div class="help-block">' + data.errors.parada + "</div>"
); // add the actual error message under our input
}
}
});
event.preventDefault();
});
});