Coder Social home page Coder Social logo

aja.js's People

Contributors

dwo avatar e-jigsaw avatar jsdotcr avatar kennynaoh avatar krampstudio avatar oculus42 avatar palmerj3 avatar seanhak avatar

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  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aja.js's Issues

the appendQueryString function Having defects

sometimes, use aja().url('xxx.com').data({a: 1}).go();the request url will be 'xxx.com?&a=1', the query string start with ?&,it is not too bright, fix it with:

var appendQueryString = function appendQueryString(url, params) {
        var key;
        url = url || '';
        if (params) {
            var querystring = '';
            if (typeof params === 'string') {
                querystring = params;
            } else if (typeof params === 'object') {
                for (key in params) {
                    querystring += '&' + encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
                }
            }

            if (querystring.indexOf('&') === 0) {
                querystring = querystring.substr(1);
            }

            url += (url.indexOf('?') === -1 ? '?' : '&');
            url += querystring;
        }

        return url;
    };

i got some error with post method

https://github.com/krampstudio/aja.js/blob/master/src/aja.js#L450

Hi,
when i use the post method,i got something error,like this

 aja()
 .method('POST')
 .url('xxx')
 .data({__cms_uid: 1 , __cms_product: "test"})
 .go();

Chrome post like this:
2015-01-19_190909

and the server got __cms_product value : "test
__cms_uid=1"

so i review the source code,line450,params join by "\n\r" , is it ok?

i change it to "&" , error gone;

by the way,
suggest params value append this encodeURIComponent

Cannot make it work as RequireJS module

Hello! Thanks a lot for great functionality :)

I cannot make it work with RequireJS though. It just does not define the module.

I configure it like this

require.config({
    paths: {
        'myaja': '../../src/z_external/scripts/ajaJS/aja'
    }
});

I define and call it like this:

define(['myaja'], function(myaja) {
        var requirejs_aja = myaja; // here should be the reference to the module
        var global_aja = aja; // here expected the global instance
});

Here is what I get in the debugger:

  // this is Chrome dev tools debugger screen output
   var requirejs_aja = myaja; requirejs_aja = undefined // aja could not be defined as RequireJS module 
   var global_aja = aja; global_aja = aja() // Global aja is OK

There is no error from RequireJS and the module itself appears in my JS bundle but not being available as RequireJS module, just as global aja(). Can you check please what is wrong? Thank you.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

String comparison with 'undefined' in _chain

return data[name] === 'undefined' ? null : data[name];
should be
return data[name] === undefined ? null : data[name];

Preparing a PR. Just creating the issue to have something to refer to when submitting PR

[Ugh, removed HTML-tags that stripped styling of the bountyplugin]


Want to back this issue? Post a bounty on it!
We accept bounties via Bountysource.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/41010509-string-comparison-with-undefined-in-_chain?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github).

Objects within Objects

Hi there,

I'm attempting to send an object like the one below:

var data = {
    "wheres": {
        ResultServer: 1
    }
};

Then using:

aja()
    .method('post')
    .url('some_url')
    .data(data)
    .on('200', function(response) {
        return response
})

It appears though that what's being sent is [object Object] in the second indentation, am I doing something wrong?

I'm outputting the POST request on the receiving end, getting this:

{"wheres":"[object Object]"}

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/29481720-objects-within-objects?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github).

Issue with lower-case HTTP method

Aja converts the HTTP Method name passed with .method() to lower-case, expecting to browser to convert it to proper case when performing the XHR call. Unfortunately, Chrome don't do this properly for all methods, notably PATCH. Aja should ensure the HTTP method string is in proper uppercase to avoid these kind of problems.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

CSS stylesheet support?

I've been watching this project for a while and I was wondering, is Aja.js planning on having CSS Stylesheet support? As in being able to load stylesheets while having the API backing it up.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/29083626-css-stylesheet-support?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github).

type method is not documented

aja.type is not documented and the accepted types are not listed.

var types = ['html', 'json', 'jsonp', 'script'];

Wildcard in handler doesn't work

Hi,

The wildcard for error code handlers doesn't seem to work:

.on('success', cb)
.on('40*', function () {
    console.log('in 400 handler');
})

My code in this case is 403 and if I specify it explicitly, the handler gets called. But not with the 40*.

Cross Origin Resource Sharing?

I would like to ask if aja.js supports some parameters like CrossDomain:true in order to enable the CORS features, thanks

Possible to make 'POST' request with file(s) attachments sending?

I cannot understand how to make 'POST' request where normal form fields are combined with attached files. Generally I would get the files on the back-end with $_FILES superglobal but I do not understand how I can set $_FILES from aja's front-end side?

Can you give a hint and probably explain it in the documentation?

Handling loss of network connectivity

I do not seem to be able to trap some errors (this on Chrome) when network connectivity is lost (or server URL is unavailable).

I am getting a simple failure in the console:
aja.min.js:1 GET http://localhost:8888/server/quote/* net::ERR_CONNECTION_REFUSED
_xhr @ aja.min.js:1
json @ aja.min.js:1
go @ aja.min.js:1
getDataList @ appdata.js:265
setupContentList @ appdata.js:70
quotesInit @ quote.js:5
initializePage @ index.html:165
(anonymous) @ index.html:158
Q.triggerElementEvent @ onsenui.min.js:2
value @ onsenui.min.js:2
(anonymous) @ onsenui.min.js:2
(anonymous) @ onsenui.min.js:2
o @ onsenui.min.js:2
i @ onsenui.min.js:2
postMessage (async)
a @ onsenui.min.js:2
a @ onsenui.min.js:2
(anonymous) @ onsenui.min.js:2
_dequeueTransition @ onsenui.min.js:2
(anonymous) @ onsenui.min.js:2
(anonymous) @ onsenui.min.js:2
_dequeueTransition @ onsenui.min.js:2
(anonymous) @ onsenui.min.js:2
(anonymous) @ onsenui.min.js:2
n @ onsenui.min.js:2

This when my server is down.

Support ES6 module

aja.js should also support the ES6 module syntax :

export default aja;

but we need to check how to know if ES6 modules are supported

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/7684511-support-es6-module?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github).

minified source breaks in Firefox 36

OK I'm not entirely sure what's wrong with the minified source, but using it like so:
aja().method('post').url('/my/url').type('json').data(values) where values is a POJO, on the server side I receive all of values munged into one argument, joined together with = and \r\n. Internally it would seem that isUrlEncoded is ending up as false instead of true.
If I use the un-minified source, everything works correctly. So for my use case I have re-minified the source with YUI Compressor and then it all works fine.

Request Object not available from response

Hi, great library, my favorite Ajax lib actually ...

I see from the docs and the source that there is no obvious way to get to the request object from the response. In my case, I would like to have an emitter called in the on('end') callback that emits the url, status code and the method for logging purposes. But doesn't seem currently possible.

Happy to do a PR - where do you suggest to do this in source?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

grunt test failes

On Windows10 machine with latest node and npm running 'grunt test' gives a lot of errors when executing "eslint:dist" (eslint) task

path\to\aja.js\src\aja.js

First line:
1:4 error Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
etc....

Promises

return ES2015 promises using something like :

 aja()
    .url('/foo/bar')
    .promise()
    .then(function(data){
    })
    .catch(function(err){
    });

The goal if to easily wrap aja into a promise based flow.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26973726-promises?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github).

Extending/embedding Aja

I am working on a tiny meta-framework that I use throughout my application. One of it's features i want to improve is AJAX.

Aja seems a great choice, however:

https://github.com/krampstudio/aja.js/blob/master/src/aja.js#L254-L263

I can't extend this. My framework uses the qwery selector engine, so I would like to change this method in order to use my own engine instead.

So, how could I best extend Aja?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/29824283-extending-embedding-aja?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F6332594&utm_medium=issues&utm_source=github).

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.