I m new to jQuery and am having a couple problems with this code:
var theCommentId = ;
var buildFormName = ;
$( .comment_submit ).bind( click , function() {
theCommentId = $(this).attr( this_id );
buildFormName = ( #AddMessageForm_ + theCommentId);
});
alert(buildFormName);
This returns #AddMessageForm_1 (or 2 or 234 depending on what button is clicked). That part is working great.
But then I need to pass buildFormName
in here so I can process multiple forms with different names. The form names are generated dynamically from an id number that s appended to addMessageForm
$(buildFormName).submit(function(e) {
// process form data here...
$.post( process.php , $(this).serialize(), function(msg) {
}
The above returns no errors, but $this
is empty and I can t create the db row from an empty $this
! it works if I don t try to pass the variable buildFormName
in there. example:
$( #addMessageForm_1 ).submit(function(e) {
// process form data here...
$.post( process.php ,$(this).serialize(),function(msg){
}
罚款。 我希望,我在这里没有简单的东西。 任何帮助都受到高度赞赏。
感谢!