ajax ile değer göndermek için php-Nasıl?

0 Cevap php

test.html

<html>
    <!--
     Please see the full php-ajax tutorial at http://www.php-learn-it.com/tutorials/starting_with_php_and_ajax.html
     If you found this tutorial useful, i would apprciate a link back to this tutorial. 
     Visit http://www.php-learn-it.com for more php and ajax tutrials
     -->
    <title>php-learn-it.com - php ajax form submit</title>
    <head>      
        <script type="text/javascript" src="prototype.js"></script>
        <script>

            function sendRequest() {
                new Ajax.Request("test.php", 
                    { 
                    method: 'post', 
                    postBody: 'name='+ $F('name'),
                    onComplete: showResponse 
                    });
                }

            function showResponse(req){
                $('show').innerHTML= req.responseText;
            }
        </script>
    </head>

    <body>
        <form id="test" onSubmit="return false;">
            <input type="hidden"  name="name" id="name" value="value">
            <input type="hidden" name="somethingElse" value="test" value="submit" onClick="sendRequest()">
        </form>
        <a href="#" onclick="myForm.submit()">Post!</a>

        <div id="show"></div>
        <br/><br/>

    </body>

</html>


<?php
/*
 * Please see the full php-ajax tutorial at http://www.php-learn-it.com/tutorials/starting_with_php_and_ajax.html
 * If you found this tutorial useful, i would apprciate a link back to this tutorial. 
 * Visit http://www.php-learn-it.com for more php and ajax tutrials
 */

if($_POST["name"] == "")
    echo "name is empty";
else
    echo "you typed ".$_POST["name"];
?>

Nerede form sayesinde yanlış.

0 Cevap