• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 781
  • Last Modified:

http_request.onreadystatechange = new Function (array???);

Hello,

I'm trying to call a function with an array and a string using "new Function" at http_request.onreadystatechange.

What is being missed at #####... or how to pass it.



...
        var mystring = "teststr";
        var myarr = new Array("testarr");
       	http_request.onreadystatechange = new Function('myFunc(#####)');
...
 
 
 
    function myFunc(arr, str) {
 
    }
........

Open in new window

0
BlueJ
Asked:
BlueJ
  • 2
1 Solution
 
kurijovCommented:
http_request.onreadystatechange = function(){
  myFunc(arr, str);
  alert('myFunc has been called');
};

Have a nice day!
0
 
Xyptilon2Commented:
Don't forget to check  the readyState as well (in addition to what Kurijov said):

http.onreadystatechange=function() {
    if(http.readyState == 4) {
      myFunc(arr, str);
      alert('myFunc has been called');
    }
  }

Goodluck!
0
 
Xyptilon2Commented:
umz.. change http to http_request as per your own example :)
0
 
BlueJAuthor Commented:
:-)
Thanks! That was it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now