By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 2,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

Javascript and SSL connections.

P: 1
Hey Guys,

Before I start I have searched the forums for similar threads and there are a few that sort of cover what I'm asking about, but I havent been able to fix my problem based on those threads and I'd rather not dig up dead topics.

So heres my problem. I'm not really a web developer but I do know other programming languages. What I'm trying to make is a Firefox toolbar that can send a request to an HTTPS website and then scan it for new information. So far my code looks like this...

Expand|Select|Wrap|Line Numbers
  1. function STB_Update() 
  2. {
  3.         alert("st1");
  4.         var label = document.getElementById("STB-webct");
  5.  
  6.         var xmlhttp = false;
  7.  
  8.         try {
  9.             xmlhttp = new XMLHttpRequest();
  10.         } catch(e) { xmlhttp = false; alert("oops");}
  11.  
  12.         if(xmlhttp) {
  13.             alert("st2");
  14.             xmlhttp.open("GET", "https://*domain*/webct/populateMyWebCT.dowebct", true);
  15.             xmlhttp.onreadystatechange = function() 
  16.             {    
  17.                 alert("st3");
  18.                 if(xmlhttp.readyState == 4)
  19.                 {
  20.  
  21.                     var content = xmlhttp.responseText;
  22.                     if(!content.match(/You currently have no new grades./i)) {
  23.                         label.setAttribute("label", "*There are new grades!*");
  24.                     }
  25.                     else if(!content.match(/You currently have no entries for today./)) {
  26.                         label.setAttribute("label", "*There are new calender entries!*");
  27.                     }
  28.                     else { label.setAttribute("label", "No new WebCT Information"); }
  29.  
  30.                 }
  31.             xmlhttp.send(null);
  32.             }
  33.  
  34.     }
  35. }

Most of this code isnt mine, I've just modified it to serve my own purpose (Why reinvent the wheel?) As you can see I've added alerts in to try and debug my code, It sends me alert st1 and st2 but I never get st3 or an oops.

But I've made a few assumptions that XMLHttpRequests can do HTTPS requests aswell. And also that if Firefox is set to remember my password for this website then the request will have permission aswell.

So my questions are, can I send HTTPS requests?
Will the request sent need to authenticate with my username and password if firefox is already set to remember me (so normally when I use that URL I never even see the authentication screen.)
Also, is there anything wrong with my code?

Sorry if my questions are a bit newbish. Also, I don't know if anyone here has created a firefox toolbar before, but is there a good way of testing the javascript without remaking the xpi file every time? Its a major pain in the butt, especially if you don't get to see any progress after doing it like 20 times :S.
Jan 18 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

I don't think it's possible to make HTTPS requests unless already on the secure domain.
Jan 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.