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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 luckysheet
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码
    • ¥50 随机森林与房贷信用风险模型
    • ¥50 buildozer打包kivy app失败
    • ¥30 在vs2022里运行python代码
    • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
    • ¥15 求解 yolo算法问题
    • ¥15 虚拟机打包apk出现错误