Click here to Skip to main content
Sign Up to vote bad
good
See more: jQuery
Hi,
I am working on MVC application.I have a method in controller as below:
public ActionResult LogOn(string viewAction)
        {
            if (string.IsNullOrEmpty(viewAction))
                return View();
            else
                return null;
        }
 
Based on the viewAction i want to perform some action but this viewAction never gets initialised.I am using jquery ajax to pass parameters as below:
function Navigate(action) {
    
    $.ajax({ url: customerIdURL, data: { viewAction: "action"} });
} 
But the problem is that viewAction is always null..Please help me out.
Posted 29 Jun '12 - 3:25
Edited 29 Jun '12 - 5:04


4 solutions

function Navigate(action) {
 
    $.ajax({ url: customerIdURL, data: { viewAction: action} });
}
  Permalink  
Here is an article that will help you pass parameters:
 
Invoke Server Methods From Client Side Using jQuery AJAX in ASP.NET[^]
  Permalink  
Comments
Sandeep Mewara - 29 Jun '12 - 11:09
Good reference for jQuery Ajax, but it misses the MVC flavor in it.
I doubt if the above article covers jQuery Ajax parameters to MVC controller, have a look at this one: Refreshing content of the table using AJAX in ASP.NET MVC (jQuery DataTables and ASP.NET MVC integration - Part III)[^]
  Permalink  
use this
function Navigate(action) {
 
    $.ajax({ url: customerIdURL, data: "{ viewAction: "+ action+"}",
type="post" });
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 8,286
1 OriginalGriff 6,561
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 9 Jul 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid