如果我有a href
getJSON工作正常(获得警报消息框),但如果我使用input button
然后它不起作用(没有警报消息),下面是我的示例使用a href
和input button
,我打开萤火虫,我没有看到任何数据的回应。getJSON不能使用输入按钮
工作
<a href="'http://host/Myservice.svc/GetCustomerBy?GetCustomerBy?GetCustomerBy=?">GetCustomerBy</a>
$(function() {
$('a').click(function() {
$.getJSON(this.href, { id: '2' }, function (customer) {
alert(customer.Name);
alert(customer.Address);
});
return false;
});
});
不工作
<input type="button" id="driver" value="Load Data" />
$("#driver").click(function (event) {
$.getJSON('http://host/Myservice.svc/GetCustomerBy?GetCustomerBy=?', { id: '2' }, function (customer) {
alert(customer.Address);
alert(customer.Name);
});
});
两个URL是不同的 – 2010-11-20 20:13:24