[英]ajax function not fetching url
I have: 我有:
function makeAjaxRequest() {
var url = '/queryjob/dbname/ip';
$.ajax(url,
{
success: alert(response)
});
}
When I do a normal browser request on this url I get a response of 43(just a test response right now) 当我对此网址执行正常的浏览器请求时,得到的响应为43(现在只是测试响应)
When I click the button I have to run this function, nothing happens. 当我单击按钮时,我必须运行此功能,什么也没发生。 I don't see a get request in the log at all.
我根本没有在日志中看到任何获取请求。 Do I have some stupid syntax error or something?
我有一些愚蠢的语法错误吗? I am pretty new to js and ajax.
我对js和ajax很陌生。 I have another function that works where I get a url and act on the html response code, but this one is killing me so far.
我有另一个函数,可以在我获取url并对html响应代码进行操作的情况下工作,但到目前为止,这个函数使我丧命。
You are not calling $.ajax correctly. 您没有正确调用$ .ajax 。 Assuming you wanted to make a GET request, this is the correct syntax:
假设您要发出GET请求,这是正确的语法:
$.ajax({
type: 'GET',
url: url,
success: function(response) {
alert(response);
}
});
You could also use $.get to accomplish the same thing: 您还可以使用$ .get完成相同的操作:
$.get(url, function(response){
alert(response);
});
$.ajax({
type: "GET",
url: "/queryjob/dbname/ip",
success: function (data) {
alert(data);
}
});
Yes, it was a syntax error ;) 是的,这是语法错误;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.