tags:

views:

66

answers:

1

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?

A: 

event is a reserved word and might have special meaning depending on the context. Try naming your variable differently:

new Ajax.Request('saverating.htm', {
    parameters: { ratingValue: evt.memo, othervar: 12 }
});
Darin Dimitrov