javascript - multiple get request on button click -
is possible integrate within click event multiple request? getting adress data database. second step extracted coordinates , send them server. want pass points within buffer javascript.
$("#ok").click( function(event) { $.get(url + 'c=' + text, function(data) { result1 = data; $.ajax({ url: my_url, type: "post", data: my_data }); }); $.get(url, function(data) { result2 = data; console.log("yes"); }); });
using done. when 1 request ready , processed, let's execute other using done. see below. i've hoisted x , y make them available throughout block.
$("#ok").click( function(event) { var text = $('#st').val(); var x,y; $.get('localhost:5000/adress?' + 'c=' + text, function(data) { mydata2 = data; //json.parse not needed (var = 0; <mydata2.length; i++){ y = mydata2[i][1]; x = mydata2[i][0]; l = l.marker([y, x]).addto(map); }).done(function(){ $.ajax({ url: 'localhost:5000/long_lat', type: "post", data: {"x": x, "y": y} }).done(function(){ $.get('localhost:5000/long_lat', function(data) { mydata3 = (data); console.log("yes"); }); }); }); });
Comments
Post a Comment