?
Solved

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

Posted on 2014-07-29
13
Medium Priority
?
411 Views
Last Modified: 2015-04-30
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
0
Comment
Question by:ts84zs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +1
13 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40227838
ActiveX is disabled in IE10+ and that code is pre IE7 - you should be using

var xmlhttp = new XMLHttpRequest();
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40227840
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
 

Author Comment

by:ts84zs
ID: 40227864
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 58

Assisted Solution

by:Gary
Gary earned 2000 total points
ID: 40227875
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
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40227880
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
 

Author Comment

by:ts84zs
ID: 40227884
ok thanks a lot let me try that
0
 

Author Comment

by:ts84zs
ID: 40227887
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
 
LVL 58

Expert Comment

by:Gary
ID: 40227895
Confused - what is supposed to be happening?
How is your myfunct() called?
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40227987
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40228101
+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
 

Author Comment

by:ts84zs
ID: 40239113
thanks all i am looking into it...
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question