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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.