ajax post request

Status
Not open for further replies.

wizkid

New Member
Messages
25
Reaction score
0
Points
0
i was trying to make a post request using ajax

here's the request code
Code:
function show_comments()
{ 

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="<?php require('source_link.php');echo"$comments_add";?>";
var param="level=0";
//alert("THIS IS THE REQ URL :\n"+param+param.length);
//url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged1;
xmlHttp.open("POST",url,true);
xmlhttp.setRequestHeader("POST /"+url+"HTTP/1.1");
xmlHttp.setRequestHeader("Content-Type ", "application/x-www-form-urlencoded");
xmlHttp.setReauestHeader("Content-Length" , param.length);
xmlHttp.setRequestHeader("connection", "close");
xmlHttp.setRequestHeader("\r\n\r\n");
xmlHttp.send(param);


}
here's the php file to which data is posted
PHP:
if(($_POST['level']==0) || !isset($_POST['level']) )
   {
    //some code
   }
if($_POST['level']==1)
   {
   //some code
   }

if($_POST['level']==2)
   {
    //some code
   }

the problem is that the post request does not take place.
however when i comment out the setrequestheader lines .........the request. does work but variables dont get passed

here is the page on which i have used this code
comments.php
Edit:
solved
the error was an extra space and a mispelt request
 
Last edited:
Status
Not open for further replies.
Top