我有一个AJAX的实现,如何使用jQuery AJAX精确复制它
var request;
function sendInfo()
{
var id = document.form.bid.value;
var url="retrieve.jsp?bid="+id;
if(window.XMLHttpRequest)
{
request=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
try
{
request.onreadystatechange=getInfo;
request.open("GET",url,true);
request.send();
} catch (e)
{
alert("Unable to connect to server");
}
}
我需要在keyup上发送数据出价,将一些数据显示到'dispArea'
function getInfo()
{
if(request.readyState==4)
{
var val = request.responseText;
document.getElementById('dispArea').innerHTML=val;
}
}
使用jQuery AJAX实施相同的操作
我尝试过的事情::
$(document).ready(function(){
$('#bookid').keyup(function(){
$.ajax({
url : 'retrieve.jsp',
data : {
bid : $('bookid').val()
},
success : function(responseText){
$('#dispArea').text(responseText);
}
});
});
});
bid在检索的jsp文件中不可用。
答案 0 :(得分:0)
我在引用ID“ #bookid”时没有使用#符号。 并以html格式接收文本。
{14090233: {'newDelivery': '5009.000', 'grade': u'E10', 'timestamp': datetime.datetime(2019, 6, 21, 0, 0), 'tanksystemid': 5776, 'oldDelivery': 5009.0, 'sitecode': u'4169'}, 14129146: {'newDelivery': '17091.000', 'grade': u'Unleaded', 'timestamp': datetime.datetime(2019, 6, 24, 0, 0), 'tanksystemid': 8720, 'oldDelivery': 17091.0, 'sitecode': u'2328'}, 14118907: {'newDelivery': '13797.000', 'grade': u'Unleaded', 'timestamp': datetime.datetime(2019, 6, 23, 0, 0), 'tanksystemid': 5973, 'oldDelivery': 13797.0, 'sitecode': u'1151'}, 14145533: {'newDelivery': '8281.000', 'grade': u'PULP', 'timestamp': datetime.datetime(2019, 6, 24, 0, 0), 'tanksystemid': 5360, 'oldDelivery': 8281.0, 'sitecode': u'2212'}, 14129150: {'newDelivery': '7099.000', 'grade': u'Diesel', 'timestamp': datetime.datetime(2019, 6, 24, 0, 0), 'tanksystemid': 8724, 'oldDelivery': 7099.0, 'sitecode': u'2328'}, 14129565: {'newDelivery': '16619.100', 'grade': u'Unleaded', 'timestamp': datetime.datetime(2019, 6, 24, 0, 0), 'tanksystemid': 10012, 'oldDelivery': 16619.1, 'sitecode': u'4217'}}