ASP .NET MVC3 ajax call same function from various pages

How can I call the same action using ajax from different pages?

type: 'POST',
  url: 'Notification/GetRecentNotifications/'

I'm currently using the code above to call my action. It works for my application's home page, but when I change to other page, this doesn't work. Can anybody give me a solution? Thanks before.

Answers


Heres what I usually do to point to which controller & action to call within an ajax jquery call...

 $.ajax({
            type: "POST",
            url: '@(Url.Action("Action", "Controller"))',
            success: function (data) {

            }
        });

Use Url.Action() to build links


Need Your Help

Django populating initial data in formset

django data formset

This may be a rather simple problem. But I am trying to populate my form with initial data taken from a database. I don't really know where to start. Any advice would help.

Facing problem in Linq to sql

linq linq-to-sql

//Below mentioned class is created to understand the problem, while this is created through Linq2Sql.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.