使用 Ajax.Request 和 Starbox 时提交多个值
我正在使用 starbox 并且我有一个定义如下的函数:
document.observe('starbox:rated', saveStar);
function saveStar(event) {
new Ajax.Request('saverating.htm', {
parameters: event.memo
});
}
我可以检索事件参数(评级、平均等)在我的控制器中。但是,我还想在 Ajax 请求中发送另一个变量。我已经尝试过
new Ajax.Request('saverating.htm', {
parameters: {ratingValue: event.memo, othervar: 12}
});
,
new Ajax.Request('saverating.htm', {
var params = {ratingvalue: event.memo, othervar: 12};
parameters: params
});
但只发送 othervar
,而不发送 event.memo
。如何发送 event.memo 值以及另一个变量?我是否必须在请求之前连接评级和其他变量?这是因为 event.memo 是一个对象吗?
I'm using starbox and I have a function defined like:
document.observe('starbox:rated', saveStar);
function saveStar(event) {
new Ajax.Request('saverating.htm', {
parameters: event.memo
});
}
I can retrieve the event parameters (rated, average, etc) in my controller. However, I also want to send another variable in the Ajax request. I've tried
new Ajax.Request('saverating.htm', {
parameters: {ratingValue: event.memo, othervar: 12}
});
and
new Ajax.Request('saverating.htm', {
var params = {ratingvalue: event.memo, othervar: 12};
parameters: params
});
but that only sends the othervar
, not the event.memo
. How can I send the event.memo value as well as another variable? Do I have to concatenate the rating and the othervar before the request? Is this because event.memo is an object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
event
是一个保留字,根据上下文可能具有特殊含义。尝试以不同的方式命名变量:event
is a reserved word and might have special meaning depending on the context. Try naming your variable differently: