복붙노트

[JQUERY] 어떻게 재 지정없이 HTML 양식을 제출

JQUERY

어떻게 재 지정없이 HTML 양식을 제출

해결법


  1. 1.당신이 원하는 것을 달성하기 위해, 당신은 다음과 같이 jQuery를 아약스를 사용해야합니다 :

    당신이 원하는 것을 달성하기 위해, 당신은 다음과 같이 jQuery를 아약스를 사용해야합니다 :

    $('#myForm').submit(function(e){
        e.preventDefault();
        $.ajax({
            url: '/Car/Edit/17/',
            type: 'post',
            data:$('#myForm').serialize(),
            success:function(){
                // Whatever you want to do after the form is successfully submitted
            }
        });
    });
    

    또한이 하나를 시도해보십시오 :

    function SubForm(e){
        e.preventDefault();
        var url = $(this).closest('form').attr('action'),
        data = $(this).closest('form').serialize();
        $.ajax({
            url: url,
            type: 'post',
            data: data,
            success: function(){
               // Whatever you want to do after the form is successfully submitted
           }
       });
    }
    

    이것은 완벽하게 일했다. 내가 Html.ActionLink에서이 함수를 호출 (...)

    function SubForm (){
        $.ajax({
            url: '/Person/Edit/@Model.Id/',
            type: 'post',
            data: $('#myForm').serialize(),
            success: function(){
                alert("worked");
            }
        });
    }
    

  2. 2.당신은 눈에 보이지 않는