如果我有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