双参数url传递不起作用,因为弹出错误警报 收到警报错误:
语法错误:意外的字符串
我在firefox中遇到了一个新错误。
SyntaxError:JSON.parse:JSON数据后的意外非空白字符
function GetSlotTime() {
var SlotDate = document.getElementById('field3-datepicker').value;
var SlotType = document.getElementById('field6').value;
alert(SlotDate);
alert(SlotType);
$.ajax({
type: 'GET',
url:"@Href("~")AjaxMethods/GetSlotTime.cshtml?SlotDate="+SlotDate+"&SlotType="+SlotType,
dataType: "json",
contentType: "application/json",
success: function (data) {
alert(data);
des = data;
$("#field4").append(des);
},
error: function (XMLHttpRequest, textstatus, error) {
alert(error);
}
});
}
答案 0 :(得分:0)
不知道你想做什么,但你可以用#34;数据"发送params:
$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
所以你可以使用
data: { SlotDate: SlotDate, SlotType: SlotType }
答案 1 :(得分:0)
以下是一个例子:
$.ajax({
type: "GET",
url: "load_page.php",
data: 'slotdate='+slotdate+'&slottype='+slottype,
dataType: "html",
success: function(msg){
if(msg!=0)
{
$('#pageContent').html(msg);
}
}
});
然后在PHP(例如)中执行:
$slottype = $_GET['slottype'];
等