squiblo Posted April 15, 2010 Share Posted April 15, 2010 I have a Javascript file named 'javascript.js' when i put 'script 1' inside it (without script 2) it works perfectly but when i put them both of the scripts in together, 'script 2' does not work while 'script 1' still works. Script 1 //chat 1 input var http_request1 = false; function makePOSTRequest1(url, parameters) { http_request1 = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request1 = new XMLHttpRequest(); if (http_request1.overrideMimeType) { // set type accordingly to anticipated content type //http_request1.overrideMimeType('text/xml'); http_request1.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request1 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request1) { alert('Cannot create XMLHTTP instance'); return false; } http_request1.onreadystatechange = alertContents1; http_request1.open('POST', url, true); http_request1.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request1.setRequestHeader("Content-length", parameters.length); http_request1.setRequestHeader("Connection", "close"); http_request1.send(parameters); } function alertContents1() { if (http_request1.readyState == 4) { if (http_request1.status == 200) { //alert(http_request1.responseText); result1 = http_request1.responseText; document.getElementById('myspan').innerHTML = result1; } else { alert('There was a problem with the request.'); } } } function get1(obj) { var poststr1 = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ); var replaceAND1= "and38"; var message1 = poststr1.replace(/&/g, replaceAND1); document.getElementById("mytextarea1").value = ''; makePOSTRequest1('http://localhost/includes/chat/textarea_input/sql1.php', message1); } Script 2 var http_request2 = false; function makePOSTRequest2(url, parameters) { http_request2 = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request2 = new XMLHttpRequest(); if (http_request2.overrideMimeType) { // set type accordingly to anticipated content type //http_request2.overrideMimeType('text/xml'); http_request2.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request2 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request2 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request2) { alert('Cannot create XMLHTTP instance'); return false; } http_request2.onreadystatechange = alertContents2; http_request2.open('POST', url, true); http_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request2.setRequestHeader("Content-length", parameters.length); http_request2.setRequestHeader("Connection", "close"); http_request2.send(parameters); } function alertContents2() { if (http_request2.readyState == 4) { if (http_request2.status == 200) { //alert(http_request2.responseText); result2 = http_request2.responseText; document.getElementById('myspan').innerHTML = result2; } else { alert('There was a problem with the request.'); } } } function get2(obj) { var poststr2 = "mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value ); var replaceAND2= "and38"; var message2 = poststr2.replace(/&/g, replaceAND2); document.getElementById("mytextarea2").value = ''; makePOSTRequest2('http://localhost/includes/chat/textarea_input/sql2.php', message2); } Quote Link to comment https://forums.phpfreaks.com/topic/198698-two-scripts-dont-work-together/ Share on other sites More sharing options...
squiblo Posted April 20, 2010 Author Share Posted April 20, 2010 I still cant figure this one out :-\ Quote Link to comment https://forums.phpfreaks.com/topic/198698-two-scripts-dont-work-together/#findComment-1045009 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.