我寫了下面的Javascript,但得到錯誤'無效的JSON原語:strSeason'。其餘的語法看起來不錯,但我似乎無法得到正確的'數據'參數。任何人都可以幫助我的語法?C#中的JSON語法#
TagBuilder script = new TagBuilder("script");
script.Attributes.Add("type", "text/javascript");
script.Attributes.Add("language", "javascript");
// ReSharper disable LocalizableElement
script.InnerHtml = @"
$.ajax({
type: 'POST',
async: true,
contentType: 'application/json; charset=utf-8',
dataType: 'html',
url: '/en-US/" + areaName + '/' + controllerName + '/' + actionName + @"',
data: " + "{strSeason:'" + season + "', strTeam:'" + team + @"'},
beforeSend: function(xhr){
$(this).addClass('ajaxRefreshing');
xhr.setRequestHeader('X-Client', 'jQuery');
},
success: function(html){
$(this).html(html);
},
complete: function(){
$(this).removeClass('ajaxRefreshing');
}
});
";
你可以驗證你的json字符串http://jsonlint.com – 2012-07-24 08:49:39
不應該數據類型是「json」嗎? – Steve 2012-07-24 08:51:35