0

First try to relate the things. I have a dynamic created div which I was loading from $().Load() something like this

 $(elem).load("BarChart");

Note: elem id dynamically created div at the same moment

untill this all working fine but now I want to send selected Data

something like this

       $(elem).load("BarChart",{Values: values});

Note: BarChart is Partial View. which is calling Controller Method but not able to find the values passed from load

controller Method

 public ActionResult BarChart(List<String> Values)
        {
            foreach (var v in Values)
            {
                lstPointSeries = Utility.GetPointSeries(Session["DbName"].ToString(), Session["AccountGroupName"].ToString(), null, AggregrationType.Total, v, null);
            }
            ViewBag.pointSeries = lstPointSeries;

            return PartialView();
        }

Note: Values is null

EDIT:

var values are list of selected checkbox from UI. like this something like this

values = ["first","second","third","fourth"];

var values = $('input:checkbox:checked.XAxisrowCheckbox').map(function () {
            return $(this).closest('td').next().text();
        }).get();
7
  • 1
    is values you are sending is array or object format? Commented Aug 18, 2015 at 12:18
  • @GuruprasadRao see the edit Commented Aug 18, 2015 at 12:21
  • did you try stringifying the values? like values=JSON.stringify(values)? and just try sending values instead of {Values:values} Commented Aug 18, 2015 at 12:29
  • @GuruprasadRao i tried sending only values but not by stringifying can you elaborate on it Commented Aug 18, 2015 at 12:34
  • did that work? sending just values? Commented Aug 18, 2015 at 12:39

1 Answer 1

2

I tried your code, and it works fine

Try this:

url = urlHelper.CommonHelper("", "About", "TestAction");
$("#TestDivId").load(url, { Values: ["aaa","bbb"] });
public ActionResult TestAction(List<string> Values) { return View(); }

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

how ? can you post your code... I am getting null values at controller
url = urlHelper.CommonHelper("", "About", "TestAction"); $("#TestDivId").load(url, { Values: ["aaa","bbb"] });`` public ActionResult TestAction(List<string> Values) { return View(); }
will check and let you know

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.