MVCWebサイトプロジェクトでjqueryを使用しています。
'testController'という単純なC#コントローラーがあります。
public class testController
{
public string test(string id)
{
return id;
}
}
..そしてそれを使用するjavascript関数:
function myfunct(sData) {
$.ajax({
type: "POST",
async: false,
datatype: "json",
url: '/test/test',
data: '{' + sData + '}', //Not Working if I set sData = "id:'Hello'"
//Work if I write data = { id:'hello'},
success: function (json) {
alert(json); //Need to return 'Hello'
}
});
}
..「データ」パラメータを動的に割り当てる方法はありますか?