Advertisement

12.13.2006 at 01:58PM PST, ID: 22092579
[x]
Attachment Details

pass variable with http_request.onreadystatechange?

Asked by SandyCooke in JavaScript

Tags: variable, alertcontents

Hello Experts

This works:

//////////////////////////////////////////////////////////////////////////////////////////////

function xhr(url, vars) {
...
      http_request.onreadystatechange = alertContents;
...
}
      
function alertContents() {
...
      document.getElementById('my_span').innerHTML = result;
...
}

//////////////////////////////////////////////////////////////////////////////////////////////

but I would like to do this:

//////////////////////////////////////////////////////////////////////////////////////////////

function xhr(url, vars, response_location) {
...
      http_request.onreadystatechange = alertContents(response_location);
...
}
      
function alertContents(response_location) {
...
      document.getElementById(response_location).innerHTML = result;
...
}

//////////////////////////////////////////////////////////////////////////////////////////////

Is this possible?

SandyStart Free Trial
[+][-]12.13.2006 at 02:22PM PST, ID: 18134576

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: variable, alertcontents
Sign Up Now!
Solution Provided By: HyperBPP
Participating Experts: 1
Solution Grade: A
 
 
[+][-]12.19.2006 at 11:19AM PST, ID: 18168159

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32