weixin_33725270 2017-03-31 10:38 采纳率: 0%
浏览 50

脚本不起作用(ASP.NET MVC)

I have script for recording video

Here is code of it

var fileName;
stop.onclick = function () {
    record.disabled = false;
    stop.disabled = true;
    window.onbeforeunload = null; //Solve trouble with deleting video
    preview.src = '';

    fileName = Math.round(Math.random() * 99999999) + 99999999;
    console.log(fileName);
    var full_url = document.URL; // Get current url
    var url_array = full_url.split('/') // Split the string into an array with / as separator
    var id = url_array[url_array.length - 1];  // Get the last part of the array (-1)
     function save() {
        $.ajax({
            type: 'Post',
            dataType: 'Json',
            data: {
                link: fileName,
                id: id,
            },
            url: '@Url.Action("LinkWriter", "Interwier")',
            success: function (da) {
                if (da.Result === "Success") {

                    alert("lol");

                } else {

                    alert('Error' + da.Message);
                }
            },
            error: function (da) {
                alert('Error');
            }
        });
    }

I try to get url with this row var id = url_array[url_array.length - 1]; // Get the last part of the array (-1)

and with this code write to table filename

 $.ajax({
            type: 'Post',
            dataType: 'Json',
            data: {
                link: fileName,
                id: id,
            },
            url: '@Url.Action("LinkWriter", "Interwier")',
            success: function (da) {
                if (da.Result === "Success") {

                    alert("lol");

                } else {

                    alert('Error' + da.Message);
                }
            },
            error: function (da) {
                alert('Error');
            }
        });
    }

but it not works.

There is my Action method for it

 [HttpPost]
    public ActionResult LinkWriter(string link, int id) {

        Link link_ = new Link
        {
            Link1 = link,
            Interwier_Id = id,

        };

        db.Link.Add(link_);
        db.SaveChanges();
        return View();
    }      

But it not works. Where is my mistake?

UPDATE

As I understood not works this

function save() {
    $.ajax({
        type: 'Post',
        dataType: 'Json',
        data: {
            link: fileName,
            id: id,
        },
        url: '@Url.Action("LinkWriter", "Interwier")',
        success: function (da) {
            if (da.Result === "Success") {

                alert("lol");

            } else {

                alert('Error' + da.Message);
            }
        },
        error: function (da) {
            alert('Error');
        }
    });
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
    • ¥15 安装svn网络有问题怎么办
    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)