foliotek / ajaxq Goto Github PK
View Code? Open in Web Editor NEWA tiny, simple jQuery plugin for sequential ajax requests
Home Page: http://foliotek.github.com/AjaxQ/
License: MIT License
A tiny, simple jQuery plugin for sequential ajax requests
Home Page: http://foliotek.github.com/AjaxQ/
License: MIT License
There's any possibility to call a callback when the queue is empty (or when its ends)?
Sounds simple enough, a way to get the currently running queue name.
There may be an easy way to do this without using timers: I want to block the next request in the queue until the previous request's callback function has finished executing. The only way I can envision this is to block the queue on the previous request, and unblock it by having the callback call an unblockQueue() [doNextRequest()?] method on ajaxq.
the clear function seems not to cancel any active requests and also seems to allow following calls in the queue to continue.
Have you come across this issue yourself?
The current structure is done in a way that we can just straight merge master to gh-pages branch and it will work. I think it would be better to just have a demo folder with all the files we need for gh-pages and publish just that folder to the gh-pages branch (see https://gist.github.com/cobyism/4730490).
Basically all this entails is moving the index.html to the demo folder and creating a deployment script for gh-pages, but there will be few smaller changes that will need to be made to accomplish this, so I'm creating an issue for now.
Thank you for great script. That's cool.
It would be helpful if we can give predefined second delays between each AJAX request.
That will give more human-like behaviour to our requests :)
Any chance of a feature to remove a single specific request from the queue?
`
<script src="js/lib/jquery-3.2.1.min.js"></script>
<script src="js/lib/jquery.ajaxq.min.js"></script>
<script>
var root = 'https://jsonplaceholder.typicode.com';
$.ajaxq('Queue1',{
url: root + '/posts/1',
method: 'GET',
success: function(data) {
console.log(data);
}
});
</script>
Please help me with the above code. Where am I going wrong? The error message is:
Failed to load file:///C:/Users/ranbirs/Desktop/Kendo%20RequireJS%20-%20Copy/Queue1: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Sorry for bad English.
I didn't find appropriate place to post this message. That's why it here.
Is there a way to implement feature such as cancel queue? It will be very useful.
I tried implement it myself moreover it working for me. But 1. it cancel all queues, 2. I think i've made it not so correct :) (without full knowledge of Deferred object)
Thanks
bower ajaxq#* mismatch Version declared in the json (0.0.6) is different than the resolved one (0.0.7)
Hey,
I want include default data in ajax request, but when i try this code :
` $.ajaxPrefilter(function (options, originalOptions) {
options.data = $.extend(originalOptions.data, { r: "revision" });
}); `
I have found this code at :
https://stackoverflow.com/questions/6996993/jquerys-ajaxsetup-i-would-like-to-add-default-data-for-get-requests-only
It's not work, and i have this error :
Uncaught TypeError: o.data.replace is not a function
at ajax (jquery-3.2.1.min.js:4)
at ajaxq.js:30
at enqueue (ajaxq.js:53)
at Function.$.ajaxq (ajaxq.js:28)
How use ajax filter with ajaxq ?
Tanks for help !
Have nice day !
There is an error on line 27:
if (typeof opts === "undefined") {
throw ("AjaxQ: queue name is not provided");
}
I think it should say: "AjaxQ: no options provided" or something like that. because you're not testing for qname.
Hello again,
I felt a bit uncomfortable not having unit tests for my modifications to AjaxQ, so I set up a Jasmine standalone test runner and added tests for the code I wrote. Is this something that you'd be interested in having on the main branch? I so, I could complete the test suite, adding tests for the core functions (
Thanks again for releasing this, it has really helped.
ajaxq.clear method is meant to clear active queue without aborting current request. Having that in mind, i would expect subsequent ajax requests added to the queue to be executed after running request is complete, not immediately. here is test case
$.ajaxq('queue', ajax1); // runs right away
$.ajaxq('queue', ajax2); // queues after ajax1
$.ajaxq.clear('queue'); // removes ajax2 from queue but keeps ajax1 running
$.ajaxq('queue', ajax3); // queued after ajax1 is expected, but currently runs right away even if ajax1 is not complete
I would like to request the ability to specify a callback/promise resolve function for the following events :
and on the side note, it would be great to make the auto-send of requests an option, allowing to add some number of requests to a queue, and then "start" the queue at a later point.
The isRunning methods checks to see if the queue exists which it always does in the ajax success function because the request isn't removed from the queue until the dequeue function is called AFTER all the deferred done/fail functions are applied (as explicitly defined on line 41) - which is in complete contrast to the example provided in the documentation.
Hi,
Is it stopped or have you found a better solutions?
Regards
Michel
If I run ajaxq in YM module (https://github.com/ymaps/modules), it runs once and then no ajax requests sends.
`
modules.define('main-tovar-tile',function(provide, prevC) {
provide({
init: function(){
var _this = this;
$("body").on("click",".main-tovar-tile__later-link",function(){
var i =$(this).find("i");
var id = 0;
if(i.hasClass("fa-heart")){
i.removeClass("fa-heart").addClass("fa-heart-o");
}
else{
i.removeClass("fa-heart-o").addClass("fa-heart");
id = $(this).data("id");
_this.send_to_wishes(id);
}
});
},
send_to_wishes: function(id){
$.ajaxq("atb",{
type : "post",
dataType : "json",
url : "/wp/wp-admin/admin-ajax.php?action=to_wishes",
data : {id:id},
success: function(response) {
if(response.success == true) {
$(window).trigger("add_to_wishes",{count:response.data.count});
alert(response.data.count);
}
}
});
}
});
});
modules.require("main-tovar-tile",function(provide){
provide.init();
});
`
For most of the browsers ajaxQ works well.
But it seems like IE9 doesn't support `$.ajaxq`` syntax.
Did you try ajaxQ in IE9 ?
I get this error frequently in IE 9, sometimes IE10 also gives error.
Chrome, Firefox works well.
(I use jquery 1.9.1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.