Ajax can not post to current controller?

Hi guys,

I am going pretty crazy around here. Have a really strange issue with an ajax call.

This is my code (stripped) in the view index of my advertisement controller:

$script = <<< JS


 				method: "POST",

 				url: "/advertisement/index",

				data: { id: "1" }

  			}).done(function() {


			}).fail(function() {

			    console.log( "error" );




The url in the ajax call is actually the page and view that I see in my browser at that moment. So, what I basically try to do is post something to the index action of the controller that I am in at that specific moment when the above code is loaded after a key up (which i stripped out of the above code).

Now comes the strange part. The ajax call immediately goes do the fail function. I can see in firebug that it doesn’t even try to load the url. It doesn’t matter what url I try to load in the advertisement controller, it will not even try to load it. Here comes the most strange part. When I replace the controller name with any other controller name that is available in my project, it will load.

I am completely shocked and have no idea what is causing this strange problem.

Who can help me and give me a hint what is going wrong?


It seems it has something to do with the word “advertisement”. When I rename the controller, view folder and above code to “advertisements” it still doesn’t work. When I change the name to “addvertisement” it works???


that seems weird. How are you calling the function? Also, have you tried using


for the url…it might help the url problem.

The Ajax call is not in a function.

I will give your suggestion a try later today. Will reply here with the result.

How can I use the code given within my code above?