tags:

views:

19

answers:

1

I'm doing the simplest ajax request possible:

public ActionResult SayHello()
    {
        return Content("YYAAAY");
    }

//////////

<div id="Div1">
    <%= Ajax.ActionLink("SAY HELLO", "SayHello", new AjaxOptions { UpdateTargetId = "Div1" })%>
    </div>

It works when I start an empty ASP.NET MVC project, but when I use it in my current project, it displays the whole page recursively instead of YYAAAY phrase only.

Where might be the problem?

+1  A: 

I suspect you have an unrelated javascript error that is causing it to use the default action (link) instead of retrieving the content via AJAX. Use Firefox/Firebug and examine the console or turn on script debugging in IE and see.

tvanfosson
I just checked it with FireBug. When I click on it, it makes a POST request and gets the whole page in the response field. No errors noticed...
Alex
I don't usually use Ajax.ActionLink -- can you show us the generated HTML? Also, have you checked to see if there is a javascript error that occurs earlier, say when the page originally loads, that might prevent a handler from being applied?
tvanfosson
I solved it by using jQuery. So much better! :)
Alex