JQuery Ajax Get passing parameters

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-04-23T15:20:10Z Indexed on 2010/04/23 15:23 UTC
Read the original article Hit count: 244

Filed under:
|

Hi,

I am working on my first MVC application and am running into a bit of a problem. I have a data table that when a row is clicked, I want to return the detail from that row. I have a function set up as:

function rowClick(item)
{
    $("#detailInfo").data("width.dialog", 800); 
    $.ajax({
        type: "GET",
        contentType: "application/json; charset=utf-8",
        url: "<%= Url.Action("GetDetails", "WarningRecognition")%>",
        data: "",
        dataType: "json",
        success: function(data) {//do some stuff...and show results}
 }

The problem I am running into is the passing of the "item". I calls the Controller function that looks like this:

public JsonResult GetDetails(string sDetail)
    {
        Debug.WriteLine(Request.QueryString["sDetail"]);
        Debug.WriteLine("sDetail: " + sDetail);
        var myDetailsDao = new WarnRecogDetailsDao();

        return new JsonResult { Data = myDetailsDao.SelectDetailedInfo(Convert.ToInt32(sDetail)) };
    }

But it never shows anything as the the "sDetail". It does hit the function but nothing is passed to it.

So, I have read where you pass the parameter via the data but I have tried every combination I can think of and it never shows up. Tried:

data: {"item"} data: {sDetail[item]} data: {sDetail[" + item + "]}

Any help is greatly appreciated. Thanks in advance.

Geo...

© Stack Overflow or respective owner

Related posts about mvc

Related posts about jQuery