krampstudio / aja.js Goto Github PK
View Code? Open in Web Editor NEWAjax without XML : Asynchronous JavaScript and JavaScript/JSON(P)
Home Page: http://krampstudio.github.io/aja.js/
License: MIT License
Ajax without XML : Asynchronous JavaScript and JavaScript/JSON(P)
Home Page: http://krampstudio.github.io/aja.js/
License: MIT License
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;
};
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();
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
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.
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.
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]"}
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.
.on('end', function() {stuff}) is not documented and it is very useful.
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).thx.
aja.type is not documented and the accepted types are not listed.
var types = ['html', 'json', 'jsonp', 'script'];
in ajaGo.html
data.into
can be a Node.List so the forEach
method will not 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*
.
I would like to ask if aja.js supports some parameters like CrossDomain:true in order to enable the CORS features, thanks
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?
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.
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).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.
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.
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....
Looked at the docs and didn't saw anything straightforward to do it.
Any event like .on('progress', () => {})
or something like that?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
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).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).Currently the library cannot be used in common-js like environments or projects using browserify.
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.