views:

35

answers:

1

Hello, This has been bothering me for ages and I tried everything and I cannot get it to work.

Here is my function currently

   function example1() {
   var xmlhttp = new XMLHttpRequest();
   xmlhttp.open("GET", url,true);
   xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4) {
      data=(xmlhttp.responseText);
      }
     }
  xmlhttp.send(null);
 }

I would like to be able to get "data" out of that function that I can then in another function return some regrex on AND I would like to be able to make "url" dependent on user input

I hope someone can help me, this is driving me extremely crazy.

Thanks for you time

A: 

XmlHttpRequest doesn't work across domain, so if a user, say, submits http://google.com, it won't work. However, if you want to get data from your own site, and have them input a url from your own site, then the HTML of url would be included in

xmlhttp.responseHtml;
codersarepeople
sorry that is not myy problem. "I would like to be able to get "data" out of that function that I can then in another function return some regrex on AND I would like to be able to make "url" dependent on user input"
jigh
Oh sorry about that. To get user input, lets say you have a var url, then change it to this:var data = example1(url);So instead of sayingdata=(xmlhttp.responseText);sayreturn xmlhttp.responseText;
codersarepeople
I'm still having trouble. I have found another reason why I can't continue so I'm giving up on the whole idea (for now)Thanks anyway
jigh