A:
I am writing an AJAX application.
Here is a piece of my code:
http.open("GET", fullURL, true);
http.onreadystatechange = handleHttpResponse;
the handleHttpResponse is the function that processes the returned data.
If I wanted to pass a string in to handleHttpResponse, I use:
= handleHttpResponse(user_name);
function handleHttpResponse_remtrip(string) {
alert(string);
.. other code ..
}
This generates a "Type mismatch" error. What gives?
B:
if you do this:
http.onreadystatechange = handleHttpResponse(user_name);
then you are assigning the returned value of handleHttpResponse and not the function itself.
You could try this:
http.onreadystatechange = createFunc(user_name);
function createFunc(v) {
return function() {
alert(v);
}
}