jquery 自动完成 url 损坏
jquery autocomplete url corrupt
我陷入了奇怪的境地。我正在使用 jquery 的自动完成功能。我已将我的 URL 映射到,但我得到 404.
现在,当我查看控制台时,我的 URL 显示如下:
myProject-dashboard-svc/organization/[object%20Object]
虽然我的实际 URL 就像 ../organization/suggestion
下面是我的完整 jquery 代码
$(function() {
$("#searchByText").autocomplete({
source:function(request,response){
$.get({
url:"../organization/suggestion",
dataType:"json",
contentType: "application/json",
data:{
q:request.term
},
success:function(data){
response(data);
}
})
}
})
});
<input type="text" id="searchByText" hidden="true" name="searchByText" placeholder="enter name" class="autoComplete">
请告诉我为什么 URL 会这样显示。
顺便说一句,我已经在 Chrome 和 Mozilla 中签入,并且我有 jquery-ui-jQuery-autocomplete 和 jQuery 插件。
尝试将数据作为字符串而不是 json 对象发送。
;)
$(function() {
$("#searchByText").autocomplete({
source:function(request,response){
$.get({
url:"../organization/suggestion",
dataType:"json",
contentType: "application/json",
data: {"q:" + JSON.stringify(request.term) }, // Look here!
success:function(data){
response(data);
}
})
}
})
});
您应该检查签名以获得 https://api.jquery.com/jquery.get/。
如果你想使用 get 你应该这样做
$.get("../organization/suggestion", {"q":request.term},function(data){
response(data);
},"json");
或者您可以将 $.get 替换为 $.ajax
我陷入了奇怪的境地。我正在使用 jquery 的自动完成功能。我已将我的 URL 映射到,但我得到 404.
现在,当我查看控制台时,我的 URL 显示如下:
myProject-dashboard-svc/organization/[object%20Object]
虽然我的实际 URL 就像 ../organization/suggestion
下面是我的完整 jquery 代码
$(function() {
$("#searchByText").autocomplete({
source:function(request,response){
$.get({
url:"../organization/suggestion",
dataType:"json",
contentType: "application/json",
data:{
q:request.term
},
success:function(data){
response(data);
}
})
}
})
});
<input type="text" id="searchByText" hidden="true" name="searchByText" placeholder="enter name" class="autoComplete">
请告诉我为什么 URL 会这样显示。
顺便说一句,我已经在 Chrome 和 Mozilla 中签入,并且我有 jquery-ui-jQuery-autocomplete 和 jQuery 插件。
尝试将数据作为字符串而不是 json 对象发送。
;)
$(function() {
$("#searchByText").autocomplete({
source:function(request,response){
$.get({
url:"../organization/suggestion",
dataType:"json",
contentType: "application/json",
data: {"q:" + JSON.stringify(request.term) }, // Look here!
success:function(data){
response(data);
}
})
}
})
});
您应该检查签名以获得 https://api.jquery.com/jquery.get/。 如果你想使用 get 你应该这样做
$.get("../organization/suggestion", {"q":request.term},function(data){
response(data);
},"json");
或者您可以将 $.get 替换为 $.ajax