Computing.Net > Forums > Web Development > I'm trying use XML instead of POST

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

I'm trying use XML instead of POST

Reply to Message Icon

Name: Larry21
Date: March 23, 2005 at 18:04:28 Pacific
OS: Win XP Home
CPU/Ram: P2.6+HT 512MB RAM
Comment:

Hi,

Currently what I wrote does like this: when you click the button (for example) it submits a form to a PHP document, which in tunr executes a file on the server (using EXEC)

The problem is that after you submit the form, the page must reload, and thats not neccessary here at all- as a matter of fact, no response is neccessary whatsoever here... Thats why I'm looking at XML in order to hoefully be able to accomplish the same thing (click POSTs to a PHP which runs a file on the server) but in a one-way type of thing where there is no output or response.

Now I've looked all over and could not figure out how to do this! If someone knows how to do this, I'd greatly appreciate if you could show me an example...

Here's what I have right now:


This is one HTML file with JavaScript which submits a form to the second frame of a parent window which is a PHP:

function keypress()
{
var keypress=window.event.keyCode;
if (keypress==38) {parent.right.document.keyform.key.value="upkey";}
}

And this is the PHP file:


<HTML>
<HEAD>

<form name="keyform" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="hidden" name="key" value="null">
</form>

</head>
</body>
<?php

if (isset($_POST['key']) && $_POST['key'] == "upkey") {
exec("beepA.exe");
}

?>

</html>


Any help would be very helpful!
Thanks,
Larry



Sponsored Link
Ads by Google

Response Number 1
Name: FBI Agent
Date: March 23, 2005 at 20:49:18 Pacific
Reply:

how about you give us an example of what you want. the question that you're giving is undefined. so just simply give us an idea of what you want and i could probably think of something for ya... a couple problems that you got there

<HTML>
<HEAD>

<form name="keyform" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="hidden" name="key" value="null">
</form>

</head>
</body>
<?php

if (isset($_POST['key']) && $_POST['key'] == "upkey") {
exec("beepA.exe");
}

?>

</html>


the form is supposed to go in the body, there should be a opening body tag and what the heck goes

if (isset($_POST['key']) && $_POST['key'] == "upkey")

mean?

it's asking that if the form is submited and if 'post key' = "upkey" then it exec's beepa.exe... well in the form 'post key' is assigned to "null" after the form is submitted.

maybe that was your problem? just giving a few ideas

FBI Agent

AIM: EliteAssassin187


0

Response Number 2
Name: anonproxy
Date: March 23, 2005 at 21:48:18 Pacific
Reply:

There are two ways.

One way is the hidden frame hack (now "technique"), which can be implemented more cleanly in something like OpenThought.

The second way is to use the XMLHTTPRequest Object. This is similar to a DOM 3 standard. I also have heard Google uses it in several places, but that is unconfirmed.


0

Response Number 3
Name: Larry21
Date: March 23, 2005 at 22:20:48 Pacific
Reply:

Yes exactly- right now I set the second frame to basically invisible (thats the only solution I could think of...) but then I bumped into this HTTPXMLREQUEST and it looked like it could do it, but after reading that page that you linked and others like it, I still cannot figure out how to implement it into this case...

Can you just give me example of how it might be implemeted into this kind of thing?

Attn. FBI AGENT- I dont know how it works- but it works in the end of the day. I played around and the thing simply works, so that isnt really the problem. The problem is that there is a delay from when the form is submitted until the file is actually run (very small delay, but running it from the local computer I was expecting that there should be virtually no delay at all...), and I was thinking that it may be because Apache has to compute a response page or something so I was hioping that using a 'one way' request could make the response time quicker...

I just want to add that the code above is not the whole thing but only part of it- basically the main part that does the job. (Ie. I didnt paste the master HTML that designates the frames or the full HTML of the other ones... only the basic point of what its supposed to do...)

Thanks,
Larry


0

Response Number 4
Name: anonproxy
Date: March 24, 2005 at 16:57:44 Pacific
Reply:

Here's an incomplete, untested example. Let's assume you used javascript to grab the form variables.

//open the object
var NewObject = new XMLHttpRequest();

/*configure message to call process.php and send POST data... the flag set as true is for an asynchronous connection*/
NewObject.open("POST", "processinfo.php", "true");

//now we send POST data
//Note the formatting
NewObject.send("Variable=value&Var2=value2");

I used the send() method for the POST data, not the setRequestHeader().



0

Response Number 5
Name: Larry21
Date: March 25, 2005 at 01:41:14 Pacific
Reply:

If I'm understanding this correctly, that script would POST as soon as the page loads, correct? So I'd have to place an 'if' somewhere if it were to be triggered by an event...?

Thanks


0

Related Posts

See More



Response Number 6
Name: Larry21
Date: March 25, 2005 at 06:12:30 Pacific
Reply:

I've tried to implement it but it doesnt seem to work here- this is the code:

<html>
<head>
<script type = "text/javascript">

var NewObject = new XMLHttpRequest();

function keypress()
{
var keypress=window.event.keyCode;
if (keypress==38) {NewObject.send("key=beep1");}
}

</script>
</head>

<body>
<BODY onkeydown = "keypress()";>
</body>
</html>


0

Response Number 7
Name: FBI Agent
Date: March 25, 2005 at 08:28:39 Pacific
Reply:

lol, whoops!! you have 2 <body>'s

i dont really understand the problem that you're having. if you REALLY want to use XML, i cant help you with that, but if it doesnt matter what you use, restate your question so that it's easy to understand cuz i think what you're saying is that you want to use the form to input something into some file or database and then go back to the original page. cuz that'd be easy, im just confused about it. good luck though

FBI Agent

AIM: EliteAssassin187


0

Response Number 8
Name: Larry21
Date: March 25, 2005 at 10:01:19 Pacific
Reply:

Yea you're right- two body's. I removed one but it still doesnt work. I'm trying to use XMLHTTREQUEST so that the form is submitted but nothing is returned- ie. you click the button, it triggers a file on the server (via PHP- though I could change that...) and thats that- nothing has to be returned to the browser...
AnonProxy's example is what I believe that I'm looking for, but I seem to have implemented it incorrectly...


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: I'm trying use XML instead of POST

Renaming of files.... www.computing.net/answers/webdevel/renaming-of-files/1786.html

syntax error, unexpected $end www.computing.net/answers/webdevel/syntax-error-unexpected-end/2236.html

ASP.NET or PHP www.computing.net/answers/webdevel/aspnet-or-php/2954.html