weixin_33738578 2014-03-13 09:14 采纳率: 0%
浏览 22

MVC4 AJAX发布JSON

this is my function, where i post json only

function test() {
            var imgFile = document.getElementById('image');
            //            var imgData = JSON.stringify(getBase64Image(imgElem));
            //var imgData = Convert.FormBase64String(imgElem);

            $.ajax({
                type: 'POST',
                dataType: 'json',
                url: "http://localhost:59102/Contacts/AddContact",
                data: "json=" + "{\"token\":\"8mVm/nS1OfpU+nlQLbJjqXJ7kJI=VyLGI2GEKkGgtDt0babrAw==\"}",

                success: function (returnPayload) {
                    console && console.log("request succeeded");
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    console && console.log("request failed");
                },

                processData: false,
                async: false
            });

and i dont know how to add to my data, image, i need to post json and image

this is my controller

[HttpPost]
        [AllowAnonymous]
        public JsonResult AddContact(string json, HttpPostedFileBase file)
        {}
  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 通过STM32F4实现智能清洁小车,要求用到三个以上传感器
      • ¥15 perl代码解释说明
      • ¥15 列举 五阶幻方 有多少种
      • ¥15 请教一下能人在VS中调用MATLAB绘制动态驻波
      • ¥15 VB.NET如何调用Microsoft Excel?(WPS存在时)
      • ¥15 KUKA机器人EtherNetIP通讯配置教程
      • ¥15 VB6.0如何模拟键盘组合按键
      • ¥15 python怎么替换这个word里边内容
      • ¥15 做谷歌浏览器插件的时候,怎么在background.js中优先执行其他.js文件里面函数呀?
      • ¥15 win 10家庭版非管理员账户如何获取管理权限