Forum Moderators: open

Message Too Old, No Replies

Type mismatch

         

Crump

12:22 am on Jun 13, 2006 (gmt 0)

10+ Year Member



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?

jshanman

3:33 pm on Jun 13, 2006 (gmt 0)

10+ Year Member



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);
}
}

- JS