I'm starting in javascript and I'm having a question. What is the best way to pass instructions to a Javascript function, I'll give a current example of the way I'm doing, it works, but is it a good practice?
sistema('/comando2'); //estou chamando assim
sistema(cmd)
{ if((req.state == 4) && (req.status == 200))//verifica a request do XMLHttpRequest
{
if(cmd.search("/comando1")>=0) {faz algo//}
if(cmd.search("/comando2")>=0) {faz algo//}
}
}
I would also like to know a good practice to create a request function with XMLHttpRequest, in which I change the URL parameter and values according to the need, and treat errors correctly.
Thank you