Login Register

xhr question

I want to be able to pass a different parameter everytime xhr is called. In the example -> targetcontainer is the param.
var kw = {
url: "myprogram.php",
load: function(data){
dojo.byId(targetcontainer).value = data;
},
error: function(data){
console.debug("An error occurred: ", data);
},
timeout: 2000,
form: "myForm"
};

There is a simple way in dojo.

try something like: /* GeSHi

try something like:

function doXhr(url,target){
   var t = dojo.byId(target);
   var dfd = dojo.xhrGet({
       url: url,
       load: function(data){
           t.value = data; 
       }
   });
}
doXhr("myProgram.php","targetContainer");

a better way would be to return the deferred:

function doXhr(url){ 
   return dojo.xhrGet({ url:url });
}
doXhr("myprog.php").addCallBack(function(data){
    dojo.byId("targetContainer").value = data;
});