$.get callback function doesn't work
Im trying to execute a jquery.get() request but callback and error
function are not working. This is my code:
$.get(serviceURL, {idioma:idioma}, function(links) {
links.forEach(function(link) {
link.source = nodes[link.source] || (nodes[link.source] = {name:
link.source});
link.target = nodes[link.target] || (nodes[link.target] = {name:
link.target});
});
d3.values(nodes).forEach(function(node) {
var serviceURL = "url //http://localhost:8080/..." +
node.name;
$.get(serviceURL, function(data) {
$.each(data, function(index, datos){
console.log(datos);
});
});
$(document).ajaxError(function(event, request, settings) {
console.log("event: " + event + " request:" + request);
alert("Error accessing the server");
});
});
});
There are two $.get() methods, and second is nested in first. First
$.get() is working, but second is the one is not working. Debugging with
Firebug, I see that running 2nd $.get() HTTP GET request is OK (HTTP code
200 and I see JSON object in console), but instead of execute
function(data), then it goes to the line
$(document).ajaxError(function(event, request, settings) but neither
executes error function (not showing alert or console output).
The problem is that I'm not able to see which is $.get real response, I'm
testing 2nd $.get function, outside forEach(node) and $.get links
function, passing node parameters directly to serviceURL and it works.
Could you help me, please? regards
No comments:
Post a Comment