C# Jquery函数在MVC4的客户端不起作用

C# Jquery函数在MVC4的客户端不起作用,c#,javascript,jquery,asp.net-mvc,C#,Javascript,Jquery,Asp.net Mvc,我使用了以下代码 <input type="submit" name="button" value="Run" onclick="RunEXE()" /> <script type="text/javascript"> function RunEXE() { $.post('@Url.Action("Compile", "Compile")', { fileName: $("#FileName").val(),

我使用了以下代码

<input type="submit" name="button" value="Run" onclick="RunEXE()" />


<script type="text/javascript">
function RunEXE() {

    $.post('@Url.Action("Compile", "Compile")',
        {
            fileName: $("#FileName").val(),
            programCode: $("#ProgramCode").val(),
            compileOutput: $("#CompileOutput").val(),
            language: "C",
            button: "Run"
        },
        function(data) {
            var oShell = new ActiveXObject("WScript.Shell");
            var prog = "\\\\Test-PC\\Programms\\Ramkumar\\"+data.MyString+".exe";
            oShell.Run('"' + prog + '"', 1);
        }
    );
}

函数RunEXE(){
$.post('@Url.Action(“Compile”、“Compile”),
{
文件名:$(“#文件名”).val(),
程序代码:$(“#程序代码”).val(),
compileOutput:$(“#compileOutput”).val(),
语言:“C”,
按钮:“运行”
},
功能(数据){
var oShell=newActiveXObject(“WScript.Shell”);
var prog=“\\\\Test PC\\Programms\\Ramkumar\\”+data.MyString+“.exe”;
运行(““+prog+”,1);
}
);
}


当我使用上面的代码时,jquery将运行到
var prog=“\\\\Test PC\\Programms\\Ramkumar\\”+data.MyString+“.exe”之后什么也没发生。但是,当我们不从jquery调用服务器端函数时,它工作正常。

Javascripts在客户端计算机上运行,浏览器不允许您在客户端计算机上运行exe,以确保客户端计算机的安全。如果您想在服务器端运行一些exe,那么在服务器上发送一个
ajax调用
,指示通过
c
code运行exe。

在处理提交按钮上的onclick时,尝试在函数末尾添加preventDefault()

试着改变现状

<input type="submit"> to <input type="button">
这在http请求中永远不会起作用。在哪里添加preventDefault(),只需复制上面的代码并显示给我即可
function RunEXE() {

$.post('@Url.Action("Compile", "Compile")',
    {
        fileName: $("#FileName").val(),
        programCode: $("#ProgramCode").val(),
        compileOutput: $("#CompileOutput").val(),
        language: "C",
        button: "Run"
    },
    function(data) {
        var oShell = new ActiveXObject("WScript.Shell");
        var prog = "\\\\Test-PC\\Programms\\Ramkumar\\"+data.MyString+".exe";
        oShell.Run('"' + prog + '"', 1);
    }        
);
return false; // equivalent to preventDefault() in JQuery
}