Rick,

You could try the form plugin as below

<form id="myForm" action="request_processor.cfm" method="post">
    Email: <input type="text" name="email_address" />
    Password: <input type="password" name="password" />
    <input type="submit" value="Login" />
</form>

<script type="text/javascript" src="path/to/jquery.js"></script>
    <script type="text/javascript" src="path/to/form.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            // bind 'myForm' and provide a simple callback function
            $('#myForm').ajaxForm( {
                 dataType: 'json',
                 success: function(data) {
                    $('#contentdiv').empty().fadeIn(1000).append
(data.login_message);
                  }
            });
        });
</script>


Andrew

On Dec 7, 7:31 am, Rick Faircloth <[EMAIL PROTECTED]> wrote:
> I'm trying to put my first Ajax to use by creating a login form.
>
> To get there, I'm attempting to modify the first tutorial I've found which
> I understand enough to understand what it's doing and how it's working
> with a ColdFusion backend.
>
> Anyway, my first question is:  How do I modify the code below to
> send an email address (form.email_address) and password (form.password)
> to the url: "request_processor.cfm"?
>
> The code below was just for a form with a select which, when the value
> changed,
> would cause an item in a db to be read and appear.  I'm modifying it for
> email_address
> and password fields, with a submit button.
>
>          $(document).ready(function(){
>
>              $('#contentdiv').html('&nbsp;');
>
>                 $('#idm').change(function(){  
>                     var formval = {idm:$(this).val()};
>
>                     $.ajax({
>                                   type: "POST",
>                                   url: "request_processor.cfm",
>                                   dataType: "json",
>                                   data: formval,
>                                   success: function(response){
>
> $('#contentdiv').empty().fadeIn(1000).append(response.main_dish);
>                                                               }
>                             });      
>                 });          
>          });
>
> So, I'd have:
>
> $(document).ready(function(){
>
>     $('#contentdiv').html('&nbsp;');
>
>        $('#login-button').click(function(){
>              var formval = {email address, password:$(this).val()};    
> <---  (???)
>
>              $.ajax({
>                             type:"post",
>                             url:"request_processor.cfm",
>                             dataType:"json",
>                             data:formval
>                             success:function(response){
>
> $('#contentdiv').empty().fadeIn(1000).append(response.login_message);
>                                               }
>              });
>      });
>
> });
>
> What changes need to be made?
>
> Thanks for any help!
>
> Rick

Reply via email to