1

I running jQuery on my local website which works just fine. However, when I try to run that same exact website on a remote web server, the jquery just doesn't work. I am not getting any javascript errors.

Here is what I'm simply trying to do: When I run my website locally or even when I run it locally pointing to my staging server, it works just fine as I explained. However, if I try and run it from the actual staging server, when clicking the "Generate PDF" button, it doesn't kick off the process. It's as if the value is coming back false and not executing the part I need to be executed or the js is simply not being executed. I triple verfified that the js is NOT commented out. It disables the button, but no activity. Is there anything I need to do implement or set up on the staging server?

Here is my _Layout.cshtml file:

<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2012.2.913/kendo.common.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2012.2.913/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/kendo/2012.2.913/kendo.blueopal.min.css")" rel="stylesheet" type="text/css" />
    <script src="~/Scripts/jquery-1.7.1.min.js" ></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/modernizr-2.5.3.js"></script>
    <script src="@Url.Content("~/Scripts/kendo/2012.2.913/kendo.all.min.js")"></script>
    <script src="@Url.Content("~/Scripts/kendo/2012.2.913/kendo.aspnetmvc.min.js")"></script>
</head>

Index View:

<script type="text/javascript">

    $('#btnRefresh').click(function () {
        Refresh();
    });

    function Refresh() {

        var LoanID = $("#LoanID").val();

        if (parseInt(LoanID) != 0) {
            $('#ShouldGeneratePdf').val(false)
            document.forms[0].submit();
        }
        else {
            alert("Please enter a LoanId");
        }
    }

    $('#btnGeneratePDF').click(function () {
        DisableGeneratePDF();
        $('#ShouldGeneratePdf').val(true)
    });

    function DisableGeneratePDF() {
        $('#btnGeneratePDF').attr("disabled", true);
        $('#btnRefresh').attr("disabled", true);
    }

</script>

Controller: When coming back from the js, the model.ShouldGeneratePdf value appears to be false when it should be true.

 if ((submitbutton == "Refresh") || (submitbutton == null) && (model.ShouldGeneratePdf == false))
4

1 回答 1

-1

曾经遇到过类似的问题。

你首先应该确定的是,

托管服务器上包含所有 JS/JQuery 所需文件。

尝试使用这种类型的语句来引用源文件,ResolveClientUrl("~/folder/js.js")。

我相信这可以解决问题。如果还不行,那么你可以尝试改变JScode的位置,在head部分尝试一下是否有效,如果在body部分不尝试,你可以在body的开头尝试,在body部分尝试一次正文标签的结尾。

如果这有效,那很好,否则,目前不知道。

于 2012-11-08T20:20:10.523 回答