以下是我的回复:
JBossWeb / 2.0.1.GA - 错误报告
类型状态报告
消息 / demo // ajax /运算符
描述请求的资源(/ demo // ajax /运算符)不可用
问题在于网址中的双正斜杠。 HTTP状态404 - / demo // ajax /运算符
如何修复/解决此问题?
以下是代码:
function removeOperator(opId) {
if (confirm('Are you sure you want to remove the operator?\n' +
'Ok=Remove\nCancel=Don\'t Remove')) {
$.ajax({
url: '/demo/datamgmt/updatePricingRule.do',
data: {
method: 'removeOperator',
operatorId: opId
},
error: function(jqXHR, textStatus, errorThrown) {
alert('Error: ' + textStatus);
},
dataType: 'json',
success: function(data, textStatus, jqXHR) {
if (data.result == 'success') {
$('#operator_' + opId).remove();
} else if (data.result == 'fail') {
alert(data.failMsg);
}
}
});
}
}
function processOperatorClick(opId) {
$.ajax (
{
url: '/demo/datamgmt/updatePricingRule.do',
data: {
method: 'addOperator',
operatorId: opId
},
statusCode: {
404: function() {
alert( "page not found" );
}
},
dataType: 'json',
success: function(data, textStatus, jqXHR) {
if (data.result == 'success') {
var operator = data.operator;
var $operatorRow = $('<tr />',
{
'class': 'list-item',
'data-id': operator.id,
'id' : 'operator_' + operator.id
}).css('cursor', 'pointer');
$operatorRow.append($('<td />').html(operator.customerNo == '' ? ' ' : operator.customerNo));
$operatorRow.append($('<td />').text(operator.label));
$operatorRow.append($('<td />', {'align': 'right'}).text(operator.address.city + ', ' + operator.address.state.id));
$operatorRow.appendTo($('#associatedOperatorsContainer_tbody'));
$operatorRow.click(
function() {
removeOperator(operator.id);
}
);
} else if (data.result == 'fail') {
alert('Error Message:\n' + data.failMsg);
}
}
});
}
$(document).ready(
function() {
$('.operator').click(
function() {
removeOperator($(this).data('id'));
});
$('#addOperatorsButton').click(function() {
var $div = $('#operatorSearchContainer');
if (!$div.length) {
$div = $('<div />');
$div.attr('id', 'operatorSearchContainer');
$div.dialog(
{
autoOpen: false,
modal: 'true',
title: 'Search Operators',
width: 550,
height: 600
}
);
$.ajax(
{
url: '/demo/ajax/operators',
data: {
mode: 'showform'
},
statusCode: {
404: function() {
alert( "page not found" );
}
},
dataType: 'html',
success: function(data, textStatus, jqXHR) {
$div.html(data);
}
});
}
if (!$div.dialog('isOpen'))
$div.dialog('open');
});
});
和HTML:
<tr>
<td style="padding-left: 30;"><div class="maxheight-small">
<table border="0" cellspacing="0" class="list" id="operatorsContainer" width="400">
<c:choose>
<c:when test="${not empty pricingRuleForm.map.operators}">
<thead>
<tr>
<th colspan="2">Operator</th>
<th align="right">Address</th>
</tr>
</thead>
<tbody id="associatedOperatorsContainer_tbody">
<nested:iterate property="operators" indexId="index" id="op">
<tr id="operator_${index}" class="non-select-list-item">
<td width="3%"><nested:hidden property="id" />
<a href="#" onclick="return removeOperator(${index});">
<html:img page="/images/sm_x_15x15.gif" module="/" width="15" height="15" border="0" /></a></td>
<td><nested:write property="label" /></td>
<td align="right">
${op.map.address.map.formattedAsHTML}</td>
</tr>
</nested:iterate>
</tbody>
</c:when>
<c:otherwise>
<tr><td><i>No operators assigned to this rule.</i></td></tr>
</c:otherwise>
</c:choose>
</table></div></td>
</tr>