jQuery.Form不会提交

时间:2010-06-07 10:33:07

标签: javascript jquery

我提交表单而不刷新页面,但我遇到了问题。 当我点击提交页面时,刷新并发布一些内容。 这是代码,我做错了什么? (我是新手)

jQuery 1.4.2和jQuery Form Plugin 2.43存在。

TNX

$(document).ready(function() { 
    var options = { 
        target:        '#output2',
        url:       https://graph.facebook.com/<%=fbUid%>/feed,
        type:      post,

        clearForm: true        // clear all form fields after successful submit 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //resetForm: true        // reset the form after successful submit 

        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 

    // bind to the form's submit event 
    $('#fbPostStatus').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options); 

        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false; 
    }); 
}); 

1 个答案:

答案 0 :(得分:2)

url属性中缺少引号:

 url:       https://graph.facebook.com/<%=fbUid%>/feed,

需要

 url:       "https://graph.facebook.com/<%=fbUid%>/feed",

导致JavaScript错误。 onsubmit函数中的错误使浏览器回退到默认行为(即以正常方式发送表单)。

正如@jAndy指出的那样,post也需要一些引用。

相关问题