| |
Amee Developer |
Hi friends!
Hope you are keeping up a good health and life.
I am trying to build an os app where theres a page where i need to
[CODE]
function writearticle() //the function that is called when the user
var httpRequest;
var type = arguments[0]; // get type of call
if (window.XMLHttpRequest)
else if (window.ActiveXObject)
if (!httpRequest)
// Set data to submit to server, based on the type of the
var data;
httpRequest.open('POST', 'getarticle.php', true);
httpRequest.onreadystatechange = function()
httpRequest.send(data);
--------------------------------------------------------------------------- ------------------------------
[PHP]
<?php
[/PHP]
--------------------------------------------------------------------------- --------------------------------------------------
Any help would be deeply appreciated!
send the form data to a php page using the httprequest method. I have
juxtaposed the code here. Please try and have a look and tell me how
to do it.
clicks on "write article"
{
document.getElementById('Right_Panel').innerHTML="<form> <table style=
\"width: 100%\"> <tr> <td align=\"right\" style=\"width: 116px
\">Title:</td> <td><input name=\"title\" style=\"width: 530px\" type=
\"text\" /> </td> </tr> <tr> <td align=\"right\" style=
\"width: 116px\">Category id:</td> <td><input name=\"category_id\"
type=\"text\" /></td> </tr> <tr> <td align=\"right\" style=
\"width: 116px\">Aricle Text:</td> <td><textarea name=\"content\"
style=\"width: 532px; height: 401px\"></textarea> </td> </tr>
<tr> <td align=\"right\" style=\"width: 116px\"> </td>
<td><input name=\"Submit1\" type=\"submit\" value=\"submit\" /> </
td> </tr> </table></form>"
{ // Mozilla, Safari, ...
httpRequest = new XMLHttpRequest();
if (httpRequest.overrideMimeType) {
httpRequest.overrideMimeType('text/xml');
}
}
{ // IE
try {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try {
httpRequest = new ActiveXObject
("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
{
alert('Giving up :( please use IE or Mozilla');
return false;
}
action
if (type == 0)
{
data = 'type=word';
//alert(data);
}
httpRequest.setRequestHeader('Content-Type', 'application/x-
www-form-urlencoded');
{
//alert("In httprequest block");
//alert(httpRequest.responseText);
//word = httpRequest.responseText;
if (httpRequest.readyState == 4)
{
if (httpRequest.status == 200)
{
return
httpRequest.responseText;
}
}
alert(httpRequest.responseText);
};
//else
//other requests
the code from 'setarticle.php' is
include("opensocial.php");
connect();
print "hello";
//$user_id=$_GET['user_id'];
$content=$_GET['content'];
$category_id=$_GET['category_id'];
$title=$_GET['title'];
//print $user_id . $content . $category_id;
$result = setarticle($user_id,$content,$category_id,$title);
//todo: check the result here
?>
the problem the contents of "setarticle.php" get displayed in a alert
box and nothing happens. I simply want that when the user clicks on
the "submit" button, the contents from the text boxes as shown in
getElementById thing are transfered to the setarticle.php page. The
setarticle.php is working fine and is able to post contents to
database when tried from a simple <form action > thing.