Niccaman Posted April 11, 2009 Share Posted April 11, 2009 The following is a portion of javascript functions i have running on the page in question. Whenever i add the extra variable ("pmsg") to the parameters list, i get the error message "An error has occured making the request". Why? function sendMessage(str,num) { var str2 = document.getElementById('name'+num).innerHTML; var str3 = document.getElementById('reply'+num).value; if (str3 == false) { document.getElementById('error'+num).innerHTML = '<font color="#FF0000">You didn\'t type anything</font>'; }else { var msg = document.getElementById('msgid'+num).value; document.getElementById('sendButt'+num).disabled = true; document.getElementById('error'+num).innerHTML = '<img src="/Images/loading2.gif" width="70" height="8">'; var mypostrequest=new GetXmlHttpObject() mypostrequest.onreadystatechange=function() { if (mypostrequest.readyState==4) { if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1) { document.getElementById("error"+num).innerHTML=mypostrequest.responseText }else { alert("An error has occured making the request") } } } var parameters="i="+str+"&u="+str2+"&m="+str3+"&pmsg="+msg; mypostrequest.open("POST", "inbox/msg.php", true); mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); mypostrequest.setRequestHeader("Content-length", parameters.length); mypostrequest.send(parameters); } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/153650-solved-httprequest-via-post-method/ Share on other sites More sharing options...
Niccaman Posted April 11, 2009 Author Share Posted April 11, 2009 Just found out its because of the php script somehow. I had this code to take the values: when i remove this section of coding for it, no errors occur: if (isset($_POST['p'])) { $p = cleanQuery($_POST['p']); $sql = "SELECT * FROM messages WHERE ID = '$p'"; $res = mysql_query($sql); $row = mysql_fetch_array($res); $msg = $row['msg']; $msg = ' '.nameCheck($row['userid']).' - ('.reverseDate($row['date']).') Said: '.$msg; $m .= $msg; } ....But what is my solution to this problem????? Link to comment https://forums.phpfreaks.com/topic/153650-solved-httprequest-via-post-method/#findComment-807427 Share on other sites More sharing options...
Niccaman Posted April 11, 2009 Author Share Posted April 11, 2009 ffs, once again i have fallen victim to my own stupidity by not including functions from the page i just copied the code from that calls upon them. Sorry for bothering anyone reading and trying to think about this "problem". Link to comment https://forums.phpfreaks.com/topic/153650-solved-httprequest-via-post-method/#findComment-807430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.