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?
function GetAttributesForSelectedControlType(questionType) {
alert(questionType);
$.ajax({
url: '/Wizards/GetAttributesForSelectedControlType',
contentType: "application/json",
data: {
questionType: questionType
},
success: function (result) {
alert('success');
}
});
}
如果您希望将问题类型作为参数传递,则应使用data:{qType:questionType}
它将填充函数GetAttributesForSelectedControlType
的参数qType。
Try:
function GetAttributesForSelectedControlType(questionType) {
$.get('/Wizards/GetAttributesForSelectedControlType', {questionType: questionType })
.done(function(data) {
alert('success');
});
}
You need to pass in questionType
as a data. Alternatively you could just add the follwoing into your existing ajax call.
data: {questionType: questionType }
This will work with the following action:
public ActionResult GetAttributesForSelectedControlType(string questionType)
{
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.