Jump to content

[SOLVED] httpRequest via POST method.


Niccaman

Recommended Posts

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

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?????

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.