Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Help with HTTPRequest method

View Parsed - Show only message text

MIME-Version: 1.0
Received: by 10.100.33.15 with SMTP id g15mr179873ang.14.1245349796197; Thu, 
	18 Jun 2009 11:29:56 -0700 (PDT)
Date: Thu, 18 Jun 2009 11:29:56 -0700 (PDT)
X-IP: 116.74.46.201
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) 
	Gecko/2009060215 Firefox/3.0.11 GTB5,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 Delhi-Cache (NetCache NetApp/6.0.4)
Message-ID: <d9331f2b-0d27-4291-a9e1-f39015bbe5ec@k17g2000prn.googlegroups.com>
Subject: Help with HTTPRequest method
From: Prakhar <hiprak...@gmail.com>
To: Amee Developer <amee-developer@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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


[CODE]

function writearticle() //the function that is called when the user
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\" />&nbsp;</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>&nbsp;</td>		</tr>
<tr>			<td align=\"right\" style=\"width: 116px\">&nbsp;</td>
<td><input name=\"Submit1\" type=\"submit\" value=\"submit\" />&nbsp;</
td>		</tr>	</table></form>"

var httpRequest;

        var type = arguments[0];  // get type of call

        if (window.XMLHttpRequest)
        { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        }

        else if (window.ActiveXObject)
        { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                }
            catch (e)
            {
                try {
                    httpRequest = new ActiveXObject
("Microsoft.XMLHTTP");
                	}
                catch (e) {}
            }
        }


        if (!httpRequest)
        {
            alert('Giving up :( please use IE or Mozilla');
            return false;
        }

        // Set data to submit to server, based on the type of the
action

        var data;
        if (type == 0)
        {
            data = 'type=word';
            //alert(data);
        }

        httpRequest.open('POST', 'getarticle.php', true);
        httpRequest.setRequestHeader('Content-Type', 'application/x-
www-form-urlencoded');

        httpRequest.onreadystatechange = function()
                {
                        //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

        httpRequest.send(data);

}

[/CODE]


---------------------------------------------------------------------------------------------------------
the code from 'setarticle.php' is

[PHP]

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

[/PHP]

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



Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google