TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Javascript, AJAX, E4X (http://www.talkphp.com/javascript-ajax-e4x/)
-   -   AJAX - undefined? (http://www.talkphp.com/javascript-ajax-e4x/2323-ajax-undefined.html)

Gareth 02-24-2008 02:31 PM

AJAX - undefined?
 
Hi

I recently delved into the world of AJAX, but can't seem to get it working!

The actual displaying of a message in a div without loading is working; but there's something incorrect in my definition of fields.

I am using JQuery; with this javascript:

Code:

<script type="text/javascript">

        function request(){
       
                $.ajax({
                    type: "POST",
                    url: "insert2.php",
                    data: "username=" + $("#username").value,         
                    success: function(html){
                        $("#response").html(html);
                    }
                });
               
                }
       
        </script>

and then the form is thus:

Code:

                                <form method="post" action="">

                                        <table class="formRegistration">
                                                <tr>
                                                        <td>Username:</td>
                                                        <td><input name="username" id="username" type="text" value="" maxlength="20" /></td>
                                                </tr>
                                               
                                                <tr>
                                                        <td></td>
                                                        <td><input type="button" name="submit" value="Insert" onclick="request()" /></td>

                                                </tr>
                                        </table>
                                </form>
                               
                        <div id="response">
                        <!-- Null-->
                        </div>

insert2.php is simply:

PHP Code:

echo $_POST['username']; 

Whenever I press Insert, it comes up with just "undefined" in the response div.

A live version is running here:
SUI Mock Up

Any help would be greatly appreciated :)

Sam Granger 02-24-2008 03:18 PM

Works in firefox :)

Gareth 02-24-2008 03:33 PM

Yea; just fixed it :)

Thanks Sam.


All times are GMT. The time now is 10:20 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0