【发布时间】:2011-04-15 11:24:53
【问题描述】:
我需要帮助才能提交带有如下单选按钮的 RSVP:
Attending: <input type="radio" />
Maybe Attending: <input type="radio" />
Not Attending: <input type="radio" />
Whenever someone RSVP the event, it should ratio the input to the selected (so just one radio button can only be selected), so when one option is selected, it should do an AJAX request with the $.ajax function.
我这样做了:
Attending: <input type="radio" onclick="rsvpEvent(3, 1);" />
Maybe Attending: <input type="radio" onclick="rsvpEvent(2, 1);" />
Not Attending: <input type="radio" onclick="rsvpEvent(1, 1);" />
使用 jQuery:
function rsvpEvent(rsvp, id)
{
$.ajax({
type: "GET",
url: "http://localhost:8888/update/test.php",
data: "rsvp=" + rsvp + "id=" + id,
success: function()
{
alert('rsvp: ' + rsvp + ' id: ' + id);
},
error: function()
{
alert('rsvp: ' + rsvp + ' id: ' + id);
}
});
}
这根本行不通……有什么问题?
【问题讨论】:
标签: jquery ajax radio-button