这有效:
$('#someId').live('click', function() {
var myData = '{ Periode: "something" }'
$.ajax({
type: "POST",
url: "/Nyhedsbrev/SendMailKunTilMig",
contentType: 'application/json; charset=utf-8',
data: myData,
dataType: 'json',
success: function (data) {
},
error: function () {
alert("error");
}
});
});
这不起作用,当我尝试连接它时,我该怎么办?学习是必要的,因为我以后会有很多参数。
$('#someId').live('click', function() {
var dataConcatenate = "something";
var myData = '{ Periode: ' + dataConcatenate + ' }';
$.ajax({
type: "POST",
url: "/Nyhedsbrev/SendMailKunTilMig",
contentType: 'application/json; charset=utf-8',
data: myData,
dataType: 'json',
success: function (data) {
},
error: function () {
alert("error");
}
});
});