0
Good afternoon, I need a help, I have this request get from ajax that sends to the web service, and I need to put this variable id, in the url, because inside the webservice I take this variable and treat the return, correct ? happens that when placing the variable concatenating in the url I can’t get any result the return I get is "Undefined", if I put a static value for example a number: url: "http://localhost/projectohtml/admin/users-update/55/update" then I can have the return as 55, what do I need to do for the variable to be recognized ? Thank you.
$(document).ready(function(){
var id;
$.getJSON('http://localhost/projetohtml/admin/users-list-all',function(data){
$.each(data, function(k, v){
id = v.iduser;
console.log(id);
});
});
$.ajax({
url: "http://localhost/projetohtml/admin/users-update/"+id+"/update",
method: 'GET',
data: JSON,
success: function ( response ) {
console.log(response);
console.log(id);
$.each(JSON.parse(response), function(k, v){
$("#desperson").attr("value",v.desperson);
$("#deslogin").attr("value",v.deslogin);
$("#nrphone").attr("value",v.nrphone);
$("#desemail").attr("value",v.desemail);
$("#inadmin").attr("value",v.inadmin);
});
/*window.location.replace("http://localhost/projetohtml/admin/users/users-update")*/
},
error: function () {
}
});
hmm understood, strange that I put a console.log in the answer and it comes with the value of the id inside even ajax, but you would be able to send me an example of how it would look with this false parameter ?
– Felipe Sangiorge
I updated the answer, I’m there
– Wilson Faustino
I got here guy worked super well, that’s just what I needed, I was tying everything via Ssion, now picking up the ID will be much easier, there’s only one thing I just got this log : jquery.min.js:4 [Deprecation] Synchronous Xmlhttprequest on the main thread is deprecated because of its detrimental effects to the end user’s Experience. For more help, check https://xhr.spec.whatwg.org/.
– Felipe Sangiorge
Right! Now you’ll need to put a $.ajax into the other’s Success property! So you take out the async: false, I’ll update the answer
– Wilson Faustino
Beauty I’m waiting Thanks !
– Felipe Sangiorge
Vish the only error that gave the first console.log of the first ajax and the second brings another id, I’m trying to figure out why.
– Felipe Sangiorge
Try to date quote: JSON by date: 'json'
– Wilson Faustino
I discovered here the get ta always picking up the same id it seems I have to see why, strange that the first time it ran worked.
– Felipe Sangiorge
Forget I discovered here kkkkkkkk Orelhada my auhahuahuahu
– Felipe Sangiorge