javascript code - new ActiveXObject("Microsoft.XMLHTTP")

I have an old website, it has a cold-fusion file - myfirstpage.cfm with this javascript-  code  -
<script>
function myfunct()
{
 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 xmlhttp.open("GET","http://"+document.location.host+"/Mysecondpage.cfm",false);
 xmlhttp.send();
   
  var strResponse = xmlhttp.ResponseText;
 }
</script>
   
The website is not working after user got new browser - IE 11, so i am trying to find how to fix the website
I feel the problem is with the code above, does the code written above has any issues with new browsers?

Please help & guide

thanks  so much
ts84zsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
ActiveX is disabled in IE10+ and that code is pre IE7 - you should be using

var xmlhttp = new XMLHttpRequest();
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
That's old code and I believe that ActiveX doesn't work in IE11.  Here's a link to more modern code from the W3Schools tutorial: http://www.w3schools.com/ajax/ajax_xmlhttprequest_create.asp
0
ts84zsAuthor Commented:
Do i have to import any javascript - js files to make that code you advised to work like
for e.g. -
<script src="http://aaa.bbbcom/cc/libs/ddd/somejavascriptcode.js"
            ></script>
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GaryCommented:
No, everything else is the same it's just the way you initiate the object that has changed
http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

For an easier way you may want to look at jQuery which simplifies js including ajax calls
0
Dave BaldwinFixer of ProblemsCommented:
The AJAX tutorial that Gary and I have both given you a link to covers it all.  You don't need any external files for the AJAX part of it.  You just need to update your code.
0
ts84zsAuthor Commented:
ok thanks a lot let me try that
0
ts84zsAuthor Commented:
The problem with the old code was that it was running that javascript code for the 1st time when the page is loaded
Next time it does not run that javascript code, but if i delete history and close the browser and reopen the page then that code works .... ...
code:

<script>
function myfunct()
{
 var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
 xmlhttp.open("GET","http://"+document.location.host+"/Mysecondpage.cfm",false);
 xmlhttp.send();
   
  var strResponse = xmlhttp.ResponseText;
 }
</script>


any ideas why? thanks so much
0
GaryCommented:
Confused - what is supposed to be happening?
How is your myfunct() called?
0
Dave BaldwinFixer of ProblemsCommented:
Sometimes the browser will 'cache' the AJAX content.  The way around that is to add a random number or timestamp as a query string so the complete URL will never be the same twice.
<script>
function myfunct()
{
 var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
murl="?qdat="+mstr+Math.random();
xmlhttp.open("GET","http://"+document.location.host+"/Mysecondpage.cfm"+murl,false);
xmlhttp.send();
   
  var strResponse = xmlhttp.ResponseText;
 }
</script> 

Open in new window

Shown on this page: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp
0
Ray PaseurCommented:
+1 for the recommendation of jQuery.  This article shows the "hello world" example of jQuery/AJAX.  jQuery is a good cross-browser library that implements the good parts of JavaScript.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
0
ts84zsAuthor Commented:
thanks all i am looking into it...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

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.