Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何停止jquery.post调用上的表单提交? html views.py for/求职者/个人资料/ 当我单击“提交”按钮时,阻止默认不工作,并发生整个表单提交_Javascript_Jquery_Python_Django_Post - Fatal编程技术网

Javascript 如何停止jquery.post调用上的表单提交? html views.py for/求职者/个人资料/ 当我单击“提交”按钮时,阻止默认不工作,并发生整个表单提交

Javascript 如何停止jquery.post调用上的表单提交? html views.py for/求职者/个人资料/ 当我单击“提交”按钮时,阻止默认不工作,并发生整个表单提交,javascript,jquery,python,django,post,Javascript,Jquery,Python,Django,Post,尝试返回false def addlang(request): #curform=request.POST['curform'] md=Languages() for i in request.POST.keys(): if i=='curform':continue setattr(md,i,request.POST[i]) md.save() n={ "pk": md.pk,

尝试返回false

def addlang(request):
    #curform=request.POST['curform']
    md=Languages()
    for i in request.POST.keys():
        if i=='curform':continue
        setattr(md,i,request.POST[i])
    md.save()
    n={ 
            "pk": md.pk,
            "lang":md.language,
            "read":md.read,
            "speak":md.speak,
            "write":md.write            
    }
    return HttpResponse(json.dumps(n), mimetype="application/json")
尝试返回错误

def addlang(request):
    #curform=request.POST['curform']
    md=Languages()
    for i in request.POST.keys():
        if i=='curform':continue
        setattr(md,i,request.POST[i])
    md.save()
    n={ 
            "pk": md.pk,
            "lang":md.language,
            "read":md.read,
            "speak":md.speak,
            "write":md.write            
    }
    return HttpResponse(json.dumps(n), mimetype="application/json")

尝试删除HTML表单中指定的
action=“/jobseaker/profile/”

试试这个

 $("#langForm").on("submit", function(event){    
 $.post('/jobseeker/profile/', $(this).serialize(),
 function(data){
    alert('AJAX successful');
    //CreateRow(jdata);
 }, "json"); 
 return false;
});

event.preventDefault();将停止表单的默认提交

尝试删除HTML表单中指定的
操作=“/jobseaker/profile/”

试试这个

 $("#langForm").on("submit", function(event){    
 $.post('/jobseeker/profile/', $(this).serialize(),
 function(data){
    alert('AJAX successful');
    //CreateRow(jdata);
 }, "json"); 
 return false;
});
event.preventDefault();将停止表单的默认提交

preventDefault()
放在顶部,并在最后
返回false

$("#langForm").submit(function(event){    
    $.post('/jobseeker/profile/', $(this).serialize(),
    function(data){

        /* stop form from submitting normally */
        event.preventDefault();

        alert('AJAX successful');
        //CreateRow(jdata);
    }, "json"); 
    event.preventDefault(); 
});
preventDefault()
放在顶部,并在最后返回false

$("#langForm").submit(function(event){    
    $.post('/jobseeker/profile/', $(this).serialize(),
    function(data){

        /* stop form from submitting normally */
        event.preventDefault();

        alert('AJAX successful');
        //CreateRow(jdata);
    }, "json"); 
    event.preventDefault(); 
});

浏览器中是否有任何错误console@ArunPJohny未捕获类型错误:对象[对象对象]没有方法“ajaxForm”@ArunPJohny
未捕获类型错误:对象[对象对象]没有方法“ajaxForm”localhost:8000/jobseker/profile/:236(匿名函数)localhost:8000/jobseker/profile/:236 c jquery.js:3 p.fireWith jquery.js:3 b.extend.ready jquery.js:3 H
@ArunPJohny抱歉,我有一些打字错误,浏览器中有任何错误吗console@ArunPJohny未捕获的TypeError:Object[Object Object]没有方法“ajaxForm”@ArunPJohny
Uncaught TypeError:Object[Object Object]没有方法“ajaxForm”localhost:8000/jobseker/profile/:236(匿名函数)localhost:8000/jobseker/profile/:236 c jquery.js:3 p.fireWith jquery.js:3 b.extend.ready jquery.js:3 H
@ArunPJohny抱歉我有一些打字错误抱歉我有一些打字错误。它现在正在工作。现在我用
returnfalse检查它正在工作。我还检查了
preventDefault
它也工作正常。这两个函数之间是否有任何区别?返回false相当于同时调用这两个函数,即e.preventDefault和e.stopPropagation。阻止默认值仅阻止deafult行为或类似表单提交,不影响事件流。在本例中,
event.preventDefault()
也起作用,因此返回False。对不起,我有一些输入错误。它现在正在工作。现在我用
returnfalse检查它正在工作。我还检查了
preventDefault
它也工作正常。这两个函数之间是否有任何区别?返回false相当于同时调用这两个函数,即e.preventDefault和e.stopPropagation。阻止默认值仅阻止deafult行为或类似表单提交,不影响事件流。在本例中,
event.preventDefault()
也起作用,因此返回false