A couple of functions that make js ajax calls much more intuitive. For obvious reasons, this doesn't work in Node.js
-
Go to https://github.com/xinxinw1/tools/releases and download the latest release.
-
Go to https://github.com/xinxinw1/ajax/releases and download the latest release.
-
Extract
tools.js
from the first download andajax.js
from the second download into your project directory. -
Add
<script src="tools.js"></script> <script src="ajax.js"></script>
to your html file.
-
Run
$.al($.get("ajax.js"))
to make sure it works.
See http://xinxinw1.github.io/ajax/ for a demo.
Note: The ajax library adds its functions to the $ object from the tools
library, so these are all accessed by $.<insert name>
get(a, o) get url a with parameters in o
(eg. get("test.txt", {te: 53, a: "test"})
-> GET test.txt?te=53&a=test )
get(a) same as above but with no params
post(a, o) same semantics as get(a, o) but uses http post and
Content-type application/x-www-form-urlencoded
post(a) same as above but with no params
aget(a, o, f) asyncronous get url a with params o and callback f
aget(a, o) same as above but with no callback
aget(a, f) same as aget(a, o, f) but with no params
aget(a) aget(a, o, f) but with no params or callback
apost(a, o, f) same semantics as aget(a, o, f) but with http post
apost(a, o)
apost(a, f)
apost(a)