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
- function STB_Update()
- {
- alert("st1");
- var label = document.getElementById("STB-webct");
- var xmlhttp = false;
- try {
- xmlhttp = new XMLHttpRequest();
- } catch(e) { xmlhttp = false; alert("oops");}
- if(xmlhttp) {
- alert("st2");
- xmlhttp.open("GET", "https://*domain*/webct/populateMyWebCT.dowebct", true);
- xmlhttp.onreadystatechange = function()
- {
- alert("st3");
- if(xmlhttp.readyState == 4)
- {
- var content = xmlhttp.responseText;
- if(!content.match(/You currently have no new grades./i)) {
- label.setAttribute("label", "*There are new grades!*");
- }
- else if(!content.match(/You currently have no entries for today./)) {
- label.setAttribute("label", "*There are new calender entries!*");
- }
- else { label.setAttribute("label", "No new WebCT Information"); }
- }
- xmlhttp.send(null);
- }
- }
- }
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.