未发送jQuery AJAX请求
问题描述:
我有两个变量,current_min
和current_max
。我正在设置它们的值,但AJAX不起作用。未发送jQuery AJAX请求
var current_min = $('#min').val();
var current_max = $('#max').val();
//alert(current_min+current_max);
$.ajax({
type: "POST",
url: "v.php",
data: "city=" + current_min,
success: function(response) {
alert(response);
$('#result').html(response);
}
});
我检查了控制台和错误的表现是这样的:
no element found
no element found
答
正确的方式来发送数据随着AJAX是 data: { name: "John", location: "Boston" }
因此,尝试这样
$.ajax({
type: "POST",
url: "v.php",
data: {"city": current_min},
success: function(response) {
alert(response);
$('#result').html(response);
}
});
+0
虽然为true,但这不会影响发送的请求。 OP正在使用的方法在这方面仍然有效 –
+0
是的,我尝试了这种方式..它的我的完整程序 –
共享html pls..is警报显示的东西? – guradio
'找到没有元素'不是标准的错误消息,似乎与您所显示的代码无关。你能否为你的问题添加一个更完整的代码示例。 –
没有警报显示nthng ...只是在控制台中出现错误 –