is it possible to call xhrget in two JSPs in tandem?
below are snippets of what my code looks like. When I ran it, foo.jsp ran fine and loads bar.jsp within the cargo container. But the submit button on bar.jsp do not work when i click on it.
anyone else have successfully done this tandem call or is this a bug within the toolkit?
=============================================================
foo.jsp
function fetch () {
dojo.xhrget (
url : "bar.jsp",
handleas : "text,
load: function(response) {
dojo.byId("cargo").innerHTML = response;
},
....
}
var src= dojo.byId("cargo");
src.innerHTML = "please wait ...";
}
...
=============================================================
bar.jsp
function fetch2 () {
dojo.xhrget (
url : "xxx.txt",
handleas: "text,
load: function(response) {
dojo.byId("cargo2").innerHTML = response;
},
.......
}
var src= dojo.byId("cargo2");
src.innerHTML = "please wait ...";
}

Not a bug....
It's not a problem with dojo. It's because you are just inserting text/HTML into the div. The text happens to contain JavaScript but isn't seen as JavaScript because the page has already been parsed for JavaScript. Thus, the function fetch2() doesn't exist.
Compare these two statements:
hi(); // this will fail
vs.
dojo.byId("cargo") = "";
hi(); // this will print out 'hi' on console
Calling eval on the response might work but it could cause problems if the response contains HTML and other non-JavaScript text (which I think it does). You might be able to use the dojo.deferred object but it'd kind of hard without seeing what you are trying to do.
Alternately, you could do something like this:
function insertToDiv(url, divID) {
dojo.xhrGet( {
url : url,
handleas: "text",
load: function(response) {
dojo.byId(divID).innerHTML = response;
}
});
}
dojo.addOnLoad( function() {
...
insertToDiv('bar.jsp','cargo');
...
}
Then your bar could just contain HTML like this:
<form onsubmit="insertToDiv('xxx.txt','cargo2'); return false">
...
</form>
This is off the top of my head (and admittedly a hack) though so it might not work as it is but you should get the idea. Basically you either need to have bar.jsp just return text/HTML or be able to evaluate the response of bar.js to convert it to parsed JavaScript.
Hope this helps.
Thanks
ic. so out of the box, running in tandem wont work unless we hack it.
thank you v much! your input is very helpful!