tags:

views:

342

answers:

2

I'm still new to ajax and javascript, so my apologies for missing something probably very basic and upfront.

I'm trying to submit an form onblur. I'm calling the function correctly, but I'm not sure how to reference the variables from the form. When I move from the form, I see in Firebug that it's calling the addNotes.php file, but no variables are being passed.

Here's the javascript

// Ajax to submit an edited post to the database.   
function sendNotes()   {

// we want to store the values from the form input box, then send via ajax below
var $form = $(this);        
$.ajax({
        type: "POST",
        url: "includes/addNotes.php",
        data: $form.serialize(),
        success: function(){

            }
    }); // End .ajax fucntion
return false;
} //End submit function()

Now here's the html

<form id="adminNotes" method="post" name="adminNotes" action="">
    <textarea name="notes" id="notes" onblur="sendNotes()"></textarea>
</form> 

Thanks.

A: 

Figured it out. Needed to set

var $form = $("form#adminNotes);
scatteredbomb
A: 

I haven't used .serialize, but try selecting the <form> instead of the <textarea> as you are currently doing.

Use $("#adminNotes") instead of $(this) in your sendNotes function.

Jonathon