Any way to make ajax dynamic ?
See original GitHub issueHi, I managed to get youtube results autocomplete using JSONP like that:
function jsonp(url, callback) {
var callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random());
window[callbackName] = function(data) {
delete window[callbackName];
document.body.removeChild(script);
callback(data);
};
var script = document.createElement('script');
script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + callbackName;
document.body.appendChild(script);
}
jsonp('http://suggestqueries.google.com/complete/search?hl=en&q=MYQUERY&client=youtube', function(data) {
var list = [];
for (var i = 0; i < data[1].length; i++) {
list.push(data[1][i][0]);
}
console.log(list);
new Awesomplete(document.querySelector("#search"),{list:list});
});
But there’s a little problem, I want MYQUERY to change on keypress and this way, reload the list content with new data. Is this possible ? Thanks.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:13 (1 by maintainers)
Top Results From Across the Web
How to create dynamic ajax function? - Stack Overflow
$.ajax({ url: 'file.php', type: 'POST', async: ...
Read more >Simple Dynamic JavaScript Ajax Function - CodeProject
Using only one function AjaxCall() enables dynamic functionality to run Ajax on webPages. It allows beginners to run Ajax code on any web ......
Read more >How to Create Dynamic Web Content with JavaScript and AJAX
Start by learning how to make AJAX requests using JavaScript coding examples. Then connect to JSON data and external files, and use the...
Read more >how to get the dynamic variable from the URL into the ajax url ...
how to get the dynamic variable from the URL into the ajax url string? ... I'm a bit stuck, any help is gratefully...
Read more >Dynamic Content Load using jQuery AJAX - Phppot
jQuery AJAX Dynamic Content Loading. This jQuery function receives page id and sends it to PHP a page via an AJAX request. With...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Isn’t this a perfect solution?
https://github.com/LeaVerou/awesomplete/issues/16892#issuecomment-223066074
@ralienpp I think that’s because you are creating a new instance of Awesomplete everytime you hit a key. Try setting up Awesomplete before your ajax call and outside your keyup event, and then just update
list
inside the the ajax call.