It seemed like there wasn't anything quite like this before... at least not that I could understand with my limited experience.
I was experimenting with creating a global object that contains methods, including instructions for handling AJAX requests. After setting up an event listener for a button and running some code, I encountered the following errors in the console:
Port: Could not establish connection. Receiving end does not exist. -This was deleted-.net/:1
Uncaught ReferenceError: globOject is not defined script.js:21
Port: Could not establish connection. Receiving end does not exist. -This was deleted-.net/:1
Exception in onResRdy: TypeError: Cannot read property 'htmlRes' of undefined ContentScript.js:84
I know there are likely many mistakes in my approach here. Please let me know what additional information I should provide to receive help with this issue.
var globObject = {
sendToServer: function () {
alert('you got to me at least!');
var xhr;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xhr=new XMLHttpRequest();
}
else {// code for IE6, IE5
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.open('POST', 'counterDoc.php', true);
xhr.send();
},
counterClick: function (counter) {
alert('you got here!');
counter += 1;
this.sendToServer();
}};
var button = document.getElementById('submbut').addEventListener('click',globOject.counterClick(0), true);