如何使用jqueryajax发送GET值?
我的代码如下:如何使用jqueryajax发送GET值?,jquery,ajax,Jquery,Ajax,我的代码如下: jQuery.ajax({ url: '/Control/delete', type: 'GET', contentType: 'application/json', success: function (bool) { if (bool == "deleted") { alert('record deleted'); $(".row" + currentId).hide('slow'
jQuery.ajax({
url: '/Control/delete',
type: 'GET',
contentType: 'application/json',
success: function (bool) {
if (bool == "deleted") {
alert('record deleted');
$(".row" + currentId).hide('slow');
}
else {
alert('not deleted ');
}
}
});
aa例如,我需要使用GET发送file_id(?file_id=12)参数,我如何才能这样做?只需将其添加到URL:
url: '/Control/delete?file_id=12',
使用
数据
选项:
jQuery.ajax({
type: 'GET',
data: {file_id : 12},
......
});
使用
数据
参数
jQuery.ajax({
url: '/Control/delete',
type: 'GET',
contentType: 'application/json',
data: {file_id: 12}
success: function (bool){
if(bool == "deleted"){
alert('record deleted');
$(".row"+currentId).hide('slow');
}
else{
alert('not deleted ');
}
}
});
也不是说数据
也可以是查询字符串,如:
data: "file_id=12&foo=bar"
如果不是查询字符串,jQuery将自动将其转换为查询字符串
要发送到服务器的数据。如果尚未转换为字符串,则会将其转换为查询字符串
使用此url替换为/url/delete?文件\u id=12
jQuery.ajax({
url: '/Control/delete?file_id=12',
type: 'GET',
contentType: 'application/json',
success: function (bool){
if(bool == "deleted"){
alert('record deleted');
$(".row"+currentId).hide('slow');
}
else{
alert('not deleted ');
}
}
});
使用ajax调用的
data
选项,并将一个对象与键值对一起传递给它。实际的GET方法data:“file\u id=12&someother=othervalue”
好的,那么如何编写文章呢method@ubercooluk当前位置阅读文档:)你所说的是另一种方式
//POST METHOD
$.ajax({
type: 'POST',
data: {file_id : 12},
......
});
//GET METHOD
$.ajax({
type: 'GET',
data: "file_id=12&someother=othervalue",
......
});