将JSON对象发布到服务器

I have a little problem with posting my JavaScript object to the server (asp.net 4.5 c#).

the object is created by user (i´m using jquery for that), and then user shod be able to send that object to server to process the information,

the data i need to send to the server is array of jQuery objects,

I´ve already tried this but it didnt worked :

 var sendOrder = function () {
        $.ajax({
          type: "POST",
          url: "Products.aspx/ProcessOrder",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          async: false,
          data: JSON.stringify(addedProducts),
          success: function (result) {
            debugger;
            alert(result);
          },
          error: function (result) {
            debugger;
            alert(result.responseText);
          }
        });
      }

      sendOrderInfo.bind('click', sendOrder);

server side method is :

[System.Web.Services.WebMethod]
    public static string ProcessOrder(object orderInfo) {
      return "Order Processed Successfully";
    }

and the object (array of objects) posted looks like this :

addedProducts
[
Object
product: "Cerejas"
quantity: "45"
__proto__: Object
, 
Object
product: "Farinheira"
quantity: "4"
__proto__: Object
]

Does anyone have some idea?

查看全部
weixin_33695450
weixin_33695450
2014/06/15 22:39
  • asp.net
  • ajax
  • jquery
  • 点赞
  • 收藏
  • 回答
    私信

1个回复