خرید بک لینک

Vote count: 0

Ive got problem figuring out how to pass variable to parameter of ajaxForm() function. I am getting templatedir path from hidden form field after click on form button in jquery (this works great) and I can pass it to other function but not to ajaxForm() parameter:

    var templatedir;

    // Get variable of templatedir
    $('form#contact input[type="submit"]').on('click',function(){
        templatedir = $('input[name=templatedir]').fieldValue();   
    });

    // Validate Form
    function validateform(formData, jqForm, options) {         
        ...
        // IF I CALL TEMPLATEDIR HERE IT WORKS
    }   

    // Send to PHPMailer
    $("form#contact").ajaxForm({
        url: templatedir, // IT DOESNT WORK HERE
        type: 'post', 
        beforeSubmit: validateform,
        target: '#msg',
        clearForm: true
    });

I was trying solution from this answer (How do i pass variables between functions in javascript) as you can see but it doesnt work.

asked 32 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 17 تير 1395 ساعت: 1:33

صفحه بندی