I'm using starbox and I have a function defined like:
我正在使用starbox,我有一个定义如下的函数:
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
我可以在控制器中检索事件参数(额定值,平均值等)。但是,我还想在Ajax请求中发送另一个变量。我试过了
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?
但是只发送othervar,而不是event.memo。如何发送event.memo值以及另一个变量?在请求之前我是否必须连接评级和othervar?这是因为event.memo是一个对象吗?
1 个解决方案
#1
0
event
is a reserved word and might have special meaning depending on the context. Try naming your variable differently:
event是一个保留字,可能具有特殊含义,具体取决于上下文。尝试以不同方式命名变量:
new Ajax.Request('saverating.htm', {
parameters: { ratingValue: evt.memo, othervar: 12 }
});
#1
0
event
is a reserved word and might have special meaning depending on the context. Try naming your variable differently:
event是一个保留字,可能具有特殊含义,具体取决于上下文。尝试以不同方式命名变量:
new Ajax.Request('saverating.htm', {
parameters: { ratingValue: evt.memo, othervar: 12 }
});