2011-07-22 100 views
0

我試圖做從MVC3視圖後,它不是我的控制工作正常,但是當我從海報海報post方法和jquery post方法有什麼區別?

在這裏發表相同的JSON正常工作是jQuery代碼

 var lineas = $("#articulosIngresadosTable").getRowData(); 
     var model = { 
      ObraSocialId: $("#idObraSocialTextBox").val(), 
      Lineas: lineas 
     }; 

     $.ajax({ 
      type: 'POST', 
      url: '@Url.Action("Nueva", "Factura")', 
      data: model, 
      success: function (data) { alert(JSON.stringify(data)); }, 
      dataType: "json" 
     }); 

我仔細檢查和對VAR模型的JSON是一樣的我是從海報

這裏使用的是JSON:

{"ObraSocialId":"1","Lineas":[{"codigo":"1000","Descripcion":"Articulo 1000","cantidad":"1","importe":"0","descuento":"0","importeDescuento":"0","obrasocial":"","id":"1"},{"codigo":"2000","Descripcion":"Articulo 2000","cantidad":"1","importe":"0","descuento":"0","importeDescuento":"0","obrasocial":"","id":"2"}]} 

預先感謝!

回答

0

的問題是將contentType ...

var lineas = $("#articulosIngresadosTable").getRowData(); 
var model = { 
    ObraSocialId: $("#idObraSocialTextBox").val(), 
    Lineas: lineas 
}; 

var modelString = JSON.stringify(model); 

$.ajax({ 
    type: 'POST', 
    url: '@Url.Action("Nueva", "Factura")', 
    data: modelString, 
    dataType: "json", 
    contentType: "application/json; charset=utf-8", 
    success: function (data) { alert(JSON.stringify(data)); } 
}); 
相關問題