Giter Site home page Giter Site logo

ajaxmanager's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ajaxmanager's Issues

Prevent Double Posts Does not work

Hi

I am using jquery 1.7.1 and ajax manager 3.12 and I can't get the preventDoubbleRequests to work.

I have

$.manageAjax.create('Test',
{
preventDoubbleRequests: true,
cacheResponse: false
});

      $.manageAjax.add('Test',
            {
                type: 'Post',
                data: frm,
                url: "URL',
                success: function (response)
                {

                }
            });

Yet I spam as many times as I want and it will keep posting. I asked someone else to try it as well and they get the same problem. Can you verify if I am doing anything wrong?

Thanks

Using async: true works only once

var ManagedAjax = $.manageAjax.create('Queue', { queue: true, maxRequests: 2, cacheResponse: false });

function requestajax(){
ManagedAjax.add({
async: false,
url: "ajax_request.php"
});
}

Will only execute the Ajax Request once.
(Tested with JQuery 1.4.2, FireFox 3.6.2, Firebug, Fedora12)

How to use Events/Callbacks?

Hi

I am using Ajaxmanager with uniqueName and I am wondering how to use these enhanced callbacks

for instance how do I use

managerName + 'AjaxStart' (global) event new

would it be

$.manageAjax.AaxStart({ ... });

Does this override the jquery AjaxStart?

error in getting jsonp

this pluggin throws error when tried to get jsonp with cacheResult=true

eg:
var options = {
url: 'http://gdata.youtube.com/feeds/api/videos',
type: 'get',
cache: false,
data: {
q: 'india',
alt: 'json-in-script',
'max-results': 10,
format: 5,
'start-index': 1,
orderby: 'published'
},
dataType: 'jsonp',
success: function (data) {
if (console) {
console.log('data received');
}
}
};

var someManagedAjax = $.manageAjax.create('someAjaxProfileName', { queue: true, cacheResponse: false,cacheTTL:7000 });
someManagedAjax.add(options);

cacheResponse=true: will throw error
cacheResponse= false: would not

When using cached results XHR object is not available for querying

Though it seems logical is some situations it complicates business logic counting on data in XHR object. For example if someone checks xhr.status in success callback, or examines response headers. I've prepared patch where object imitating is cached along with the data - callbacks can then examine the XHR the same as original XHR in no cached situation.

incompatible jquery 1.5.1 ?

Can't say for sure since i'm on vacation right now, but the other day when i implemented ajaxmanager 3.0 with jquery 1.5.1 nothing worked, i got some error about "label something" (they did rewrite the whole ajax pipeline tho), when i switched back to jquery 1.4.4 everything worked again.

Sorry for the vague information...

Robert

How to use with deferred ajax?

Hi

I am wondering how do you use ajax manager with deferred ajax that came out with the release of jquery 1.5?

Thanks

Undefined exception when calling clearCache in bad moment

Problem is in _createAjax method:

_createAjax: function(id, o, origSuc, origCom){
var that = this;
return function(){
if(o.beforeCreate.call(o.context || that, id, o) === false){return;}
that.inProgress++;
if(that.inProgress === 1){
$.event.trigger(that.name +'AjaxStart');
}
if(o.cacheResponse && cache[id]){
if(!cache[id].cacheTTL || cache[id].cacheTTL < 0 || ((new Date().getTime() - cache[id].timestamp) < cache[id].cacheTTL)){
that.requests[id] = {};
//START OF TWEAK
var cachedData = cache[id];
//END OF TWEAK
setTimeout(function(){
that._success.call(that, o.context || o, origSuc, cachedData._successData, 'success', cachedData, o);
that._complete.call(that, o.context || o, origCom, cachedData, 'success', id, o);
}, 0);
} else {
delete cache[id];
}
}
if(!o.cacheResponse || !cache[id]) {
if (o.async) {
that.requests[id] = $.ajax(o);
} else {
$.ajax(o);
}
}
return id;
};
}

When calling method clearCache just in time when setTimeout defers funtion invocation I had "undefined" issue with cache[id] because cache was meanwhile cleared. Fix is very easy and is surrounded by commentaries:

//START / END OF TWEAK

Calling Ajaxmanager with the returned ajaxmanger-Object not working for me.

Hi

I did this

$('#Id').live('click', function ()
{
/* Ajax request to load form into it */
var manager = $.manageAjax.create('nonCachedAjaxRequests',
{
preventDoubbleRequests: true,
cacheResponse: false
});

        manager.add
        ({
            type: 'Get',
            url: 'url here',
            success: function (response)
            {

                // stuff here

            }
        });
    });

However when I do a double click it still allows them to go through however when I use the other way(uniqueName) It all works.

Stuff like caching seem to work just the preventDoubbleRequests is having problems.

(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111

Playing around with the script i found an error occuring sometimes:

uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://192.168.161.100/js/jquery/jquery.ajaxmanager.js :: anonymous :: line 80" data: no]

which refers to this line:
var httpStatus = ahr.status,

According to this page it is not allowed to direclty read the .status value:
http://helpful.knobs-dials.com/index.php/%22Component_returned_failure_code:_0x80040111_%28NS_ERROR_NOT_AVAILABLE%29%22

(needs try/catch block as it seems, but i don't really know for sure).

PS: Adding the try{}catch(err){} block will then throw the timeout error which should be correct.

JQuery 1.5 DataType Bug

I am using JQuery 1.5.1 with the latest copy of Ajaxmanager, version 3.11 (the commit comments say "simple jquery 1.5.1 compatibility").

When making request with the option { dataType: "json" }, I get an error. In Firefox, the error says "Invalid label" and in Chrome, it says, "Uncaught SyntaxError: Unexpected token :".

It looks like this error is related to extending/overriding $.ajaxSettings. If I change this line of code:
this.opts = $.extend({}, $.ajaxSettings, $.manageAjax.defaults, opts);
To this:
this.opts = $.extend({}, $.manageAjax.defaults, opts);
Then the error goes away.

It looks like the new way of implementing this type of functionality is to use prefilters. The JQuery validation plugin was throwing similar errors and they released a fix using the new prefilter callbacks. Here are the related docs.
http://api.jquery.com/extending-ajax/

I don't understand the problem well enough to submit a patch, so I hope this is enough information to identify the problem and I'm hoping there is an easy fix for future releases.

A temporary fix is to use the option { dataType: "text json" }. This seems to correct for the problem.

few issues

Hi ,

Iโ€™m using the ajaxmanager, it is very help for me, thank you very much.
When I use it found below things, I appreciate if you can consider them and make some change in next version.

  1. _removeXHR function

In this function will call $.dequeue first then call inprogress--;
And $.dequeue will execute a _createAjax function to increase the inprogress.
If lots of ajax in the queue then will keep increase inprogress untill no ajax in the queue then
_removeXHR got chance to call inprogress--;

Idealy if 5 ajax in the queue, the inprogress should change as 1 0 1 0 1 0 1 0 1 0
But now inprogress change as 1 2 3 4 5 4 3 2 1 0

*I thinks should call inprogress--; before call $.dequeue
2. getData function
in this function got below condition Got below condition
if(!ret && this.opts.queue)
is it necessary to use this.opts.queue ?
Sometime I need change the queue as false for a while,if I do so the abort function can not work because this getData function can not return the right function

*I thinks maybe can remove && this.opts.queue

3._createAjax function

In this function if(o.cacheResponse && cache[id]) it will simulate the ajax success and complete
I think if o.beforeCreate return false also need simulate the complete function
So that we can got a chance to do something in that function when beforeCreate return false

4.actually what I really need is a gap between ajax functions
now if lots of ajax in the queue already, the script will keep dequeue and process the ajax, then the UI got no chance to process other tasks(like detect user action or show some animation) so the the page performance will not good.
so i think it is better if have a gap after one ajax complete to release the CPU for other tasks

My issues quite messy hope you can understand what i want to say.
again thank you for you provide so good plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.