0

I am using the following code

function test()
{
   GetAttributesForSelectedControlType('Phone Number');
}

function GetAttributesForSelectedControlType(questionType) {
    alert(questionType);
    $.ajax({
        url: '/Wizards/GetAttributesForSelectedControlType/' + questionType,
        type: "GET",
        contentType: "application/json",
        success: function (result) {
            alert('success');
        }

    });
}

PLEASE NOTE: QUESTIONTYPE is a STRING value and not any type..

The issue is that in the controller, I m getting a hit on "GetAttributesForSelectedControlType" function but the parameter value is coming null. I am sending string in questionType. any ideas on this?

4

3 回答 3

1
function GetAttributesForSelectedControlType(questionType) {
    alert(questionType);
    $.ajax({
        url: '/Wizards/GetAttributesForSelectedControlType',
        contentType: "application/json",
        data: {
            questionType: questionType
        },
        success: function (result) {
            alert('success');
        }
    });
}
于 2013-06-19T06:51:43.130 回答
0

尝试:

function GetAttributesForSelectedControlType(questionType) {

    $.get('/Wizards/GetAttributesForSelectedControlType', {questionType: questionType })
        .done(function(data) {
            alert('success');
    });

}

您需要questionType作为数据传入。或者,您可以将以下内容添加到现有的 ajax 调用中。

data: {questionType: questionType }

这将适用于以下操作:

public ActionResult GetAttributesForSelectedControlType(string questionType)
{
    // ...

}
于 2013-06-19T06:55:33.053 回答
0

如果您希望将问题类型作为参数传递,您应该使用data:{qType:questionType}它来填充函数的参数 qTypeGetAttributesForSelectedControlType

于 2013-06-19T06:49:44.540 回答