2012-12-20 6 views
0

직렬화해야하는 ajax 양식이 있습니다. 또한 데이터 폼의 _method를 수동으로 설정해야합니다. 다음은 현재 구현 된 내용입니다.아약스를 통해 _method 매개 변수 보내기

$.ajax({ 
      url: http://someposturl.com/object, 
      type: 'POST', 
      data: { 
       _method: method 
      }, 
      data: $('form').serialize(), 
      success: function(json) { 
       alert("YAY"); 
      }, 
      error: function(json){ 
       alert("BOO!"): 
      } 
     }); 

불행히도, 위와 같이하면 데이터 변수를 덮어 씁니다.

데이터에 _method와 serialize 된 양식이 모두 포함되도록 작성하려면 어떻게해야합니까?

답변

0

이 시도 :

var data = $('form').serialize() + "&_method=" + method; 

$.ajax({ 
     url: http://someposturl.com/object, 
     type: 'POST', 
     data: data, 
     success: function(json) { 
      alert("YAY"); 
     }, 
     error: function(json){ 
      alert("BOO!"): 
     } 
    }); 
+0

이의 변화가 해냈어! data = $ ('form') serialize() 데이터 [ '_ method'] = "POST" – OVERTONE

관련 문제