Я могу заполнить скрытые элементы только после отправки второй формы - PullRequest
0 голосов
/ 14 ноября 2011

Я могу заполнить скрытые элементы только после отправки второй формы. После первой отправки возникает ошибка. Зачем? Использование jQuery Form Plugin. Любая идея? Спасибо.

$(document).ready(function() { 
// get ID from the form name:
    $('form').submit(function(e){
     targetNum = this.name;
// call processing page:
    $('#formTarget' + targetNum).ajaxForm({ 
// populate DIV
        target: '#divTarget' + targetNum, 
        success: function() { 
            $('#divTarget' + targetNum).fadeIn('slow'); 
        } 
    }); 
    });
});

<div id='divTarget1'></div>
<form id='formTarget1' name='1' action='process2.asp' method='post'>
<input type='hidden' name='MapaID' value='1'>
<input type='submit' value='OK'>
</form>

<div id='divTarget2'></div>
<form id='formTarget2' name='2' action='process2.asp' method='post'>
<input type='hidden' name='MapaID' value='2'>
<input type='submit' value='OK'>
</form>

<div id='divTarget3'></div>
<form id='formTarget3' name='3' action='process2.asp' method='post'>
<input type='hidden' name='MapaID' value='3'>
<input type='submit' value='OK'>
</form>

Ответы [ 2 ]

0 голосов
/ 14 ноября 2011

Для этого можно использовать метод .load().

0 голосов
/ 14 ноября 2011

попробуйте это:

$(document).ready(function() {
    $(':submit').click(function(e) {
        targetNum = $('form').has(this).prop('name');
        $('#formTarget' + targetNum).ajaxForm({
            target: '#divTarget' + targetNum,
            success: function() {
                $('#divTarget' + targetNum).fadeIn('slow');
            }
        });
        return false;
    });
});
...