奇怪的问题。。。
在添加了更多的服务器端调试之后,我发现
handleLookupButton($("#select-circuit").val());
和
handleLookupButton($(this).text());
handleLookupButton($(“#选择电路”).val());
不等待服务器结果。它只是通过ajax循环,就像什么都没发生一样,没有成功,没有错误。
结束更新
给出以下jsp片段
<div id="main-controls" class="main-controls ui-widget ui-corner-all" align="center" style="padding-top: 5px;">
<form action="#" id="lookupForm">
<div align="right" style="padding-right: 10px; padding-bottom: 5px;">
<label id="select-circuit-label" class="select-label" style="font-size: 8pt; font-weight: bold">Circuit:
<input type="text" id="select-circuit" class="main-select" style="font-size: 8pt; height: 13px; width: 100px;">
</label>
<label id="select-ne-label" class="select-label" style="font-size: 8pt; font-weight: bold">NE:
<input type="text" id="select-ne" class="main-select" style="font-size: 8pt; height: 13px; width: 100px;" disabled="disabled">
</label>
<label id="select-customer-label" class="select-label" style="font-size: 8pt; font-weight: bold">Customer:
<input type="text" id="select-customer" class="main-select" style="font-size: 8pt; height: 13px; width: 100px;" disabled="disabled">
</label>
</div>
<div align="center">
<button id="lookup-button" class="lookup-button ui-widget" >Lookup</button>
</div>
</form>
</div>
<br></br>
<div id="lookup-history-container" class="ui-widget ui-widget-content ui-corner-all" align="center" style="font-size: 8pt; overflow: auto;">
<b>Lookup History</b>
<hr class="ui-widget ui-corner-all ui-header" width="80%">
<br>
<div align="left">
<ul id="lookup-history-list">
</ul>
</div>
</div>
<div id="favorites-container" class="ui-widget ui-widget-content ui-corner-all" align="center" style="font-size: 8pt; overflow: auto;">
<b>Favorites</b>
<hr class="ui-widget ui-corner-all ui-header" width="80%">
<br>
<div align="left">
<ul id="favorite-list" style="padding:2px; margin:2px; border-bottom: thin;">
<c:if test="${fn:length(favorites)> 0}">
<c:forEach var="favorite" items="${favorites}">
<c:set var="companyTrimed" value="${favorite.company}"/>
<li>
<b><span class="past-lookup-circuit"><c:out value="${favorite.circuit}" /></span></b>
<span class="delete-favorite-icon ui-icon ui-icon-trash"
style="width: 14px; float: right;"
title="DELETE this Favorite"
circuit='<c:out value="${favorite.circuit}" />'
>
</span><br>
<span class="lightly-darkened" style="padding-left: 20px;"><c:out value="${fn:substring(companyTrimed,0,20)}" />...</span>
</li>
</c:forEach>
</c:if>
</ul>
</div>
</div>
我有以下jQuery代码
// This is to look up a circuit
$("#lookup-button").live("click", function() {
handleLookupButton($("#select-circuit").val());
});
// Handle loading from history
$(".past-lookup-circuit").live("click", function() {
$("#select-circuit").removeAttr("disabled");
$("#select-ne").val("");
$("#select-ne").attr("disabled", "disabled");
$("#select-circuit").val($(this).text());
$("#select-circuit").fadeOut("slow");
$("#select-circuit").fadeIn("slow");
handleLookupButton($(this).text());
});
阿尔索
function handleLookupButton(circuit) {
var ne = "";
var data = "circuit=" + circuit + "&ne=" + ne + "&random=" + Math.random();
$("#test-results-container").html(
"<b>Checking EON...</b><br><img src='images/small-loader.gif'>");
$("#test-results-container").show();
$(".tl1-results").hide();
alert("IE8 test: \n\n>" + data + "<");
$.ajax( {
type : "POST",
url : "test.html",
data : data,
success : function(xhr) {
alert("IE8 test: \n\n" + xhr);
//.... stuff snipped here ....
},
error : function(xhr) {
$("#test-results-container").html("<span id='ajax-error-lookup'><b>Error: <b>" + xhr.statusText + "</span>");
$("#test-detail-container").html(xhr.responseText);
}
});
}
这就是问题所在。
$("#lookup-button").live
函数
handleLookupButton(circuit)
$(".past-lookup-circuit").live
功能。这个
手动Lookupbutton(电路)
对于这两个执行,var数据字符串看起来是相同的。即使我把电路号硬编码到
手动Lookupbutton(电路)
$(“#查找按钮”).live
不起作用,但是
我肯定我错过了一些简单的东西,但我被难住了。顺便说一句,这在所有其他浏览器和ie7兼容模式下都可以正常工作。