Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Help with HTTPRequest method
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Prakhar  
View profile   Translate to Translated (View Original)
 More options 18 June, 19:29
From: Prakhar <hiprak...@gmail.com>
Date: Thu, 18 Jun 2009 11:29:56 -0700 (PDT)
Local: Thurs 18 June 2009 19:29
Subject: Help with HTTPRequest method
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.

Any help would be deeply appreciated!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

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