我正面临这个问题。如果我输入localhost / web / search,网页就能触发javascript,但是如果我键入hostname / web / search,它就不会在javascript中触发提交事件。
我已经包含了如下的部分代码。
<script src="@Url.Content("~/Scripts/jquery-3.0.0.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-3.0.0.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.24.min.js")" type="text/javascript"></script>
<script type="text/javascript">
function GetFields(_ReportType) {
var procemessage = "<option value='0'> Please wait...</option>";
$("#ddlFields").html(procemessage).show();
$.ajax({
url: '@Url.Action("GetSearchFields", "Search")',
data: { iReportID: _ReportType },
cache: false,
type: "POST",
success: function (data) {
var markup = "<option value='0'>---Select Fields---</option>";
for (var x = 0; x < data.length; x++) {
markup += "<option value=" + data[x].Value + ">" + data[x].Text + "</option>";
}
$("#ddlFields").html(markup).show();
},
error: function (reponse) {
alert("error : " + reponse);
}
});
}
$(document).ready(function () {
$("#btnSubmit").click(function () {
$.ajax({
url: '@Url.Action("WebGrids", "Search")',
type: 'GET',
data: {
//'strQueryType': 'GGI_Lot_ID',
'strReport': $("#ddlReport").find("option:selected").text(),
'strQueryType': $("#ddlFields").find("option:selected").text(),
//'strValue': '110723233'
'strValue': $("#taSearchValues").text()
},
success: function (vHtml) {
$("#dvShow").html("");
$("#dvShow").html(vHtml);
},
error: function (reponse) {
//alert("123");
alert("error : " + reponse);
}
});
});
});
</script>