PanosJee
PanosJee

Reputation: 3866

Links to AJAX calls do not work

Hi all i am writing a Rails application and i include some link_to_remote links The generated code is

<a href="#" onclick="new Ajax.Request('/b10/categories/games?category=Action', {asynchronous:true, evalScripts:true}); return false;">Test</a>

That works perfectly fine on Safari and Firefox but when i try to click the link on IE7 and Opera it does not even hit the server.

Any hints ?

Upvotes: 1

Views: 183

Answers (2)

Ali
Ali

Reputation: 267049

This is a bad practice to include all of this code in the <a href> tag anyways. I suggest you make a function such as:

function doAjax(url)
{
   new Ajax.Request(url, {asynchronous:true, evalScripts:true});
   return false;
}

in the javascript code. And change the url to say instead:

<a href="#" onclick="return doAjax('/b10/categories/games?category=Action');">
Test</a>

Upvotes: 1

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

Use a fully qualified URL: http://.....

Upvotes: 1

Related Questions