Skip to content

Commit

Permalink
Version 1.0.1
Browse files Browse the repository at this point in the history
Fixed issue with JSONP callback parameter within a JSON query
  • Loading branch information
kylebarrow committed Oct 7, 2012
1 parent 9993c62 commit f996d1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
@@ -1,4 +1,4 @@
# Chibi v1.0
# Chibi v1.0.1

#### A tiny JavaScript micro-framework

Expand Down Expand Up @@ -432,7 +432,8 @@ For cross-domain requests, **ajax** uses JSONP by default but this can be overri
</head>
<body>
<script>
$({sort:'created',direction:'asc'}).ajax('https://api.github.com/users/kylebarrow/repos?callback=?','GET',function(data,status){ }); // JSONP
$().ajax('https://api.github.com/users/kylebarrow/repos?sort=created&direction=asc&callback=?','GET',function(data,status){ }); // JSONP
$({sort: "created", direction: "asc", callback: "?"}).ajax('https://api.github.com/users/kylebarrow/repos','GET',function(data,status){ }); // JSONP with JSON query
</script>
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion chibi-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion chibi.js
@@ -1,4 +1,4 @@
/*Chibi v1.0, Copyright (C) 2012 Kyle Barrow
/*Chibi v1.0.1, Copyright (C) 2012 Kyle Barrow
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Expand Down Expand Up @@ -697,6 +697,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
url += '&' + timestamp;
}

// Replace possible encoded ?
url = url.replace('=%3F', '=?');

// Replace jsonp ? with callback
if (callback && url.indexOf('=?') !== -1) {

Expand All @@ -709,10 +712,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
};
}

// JSONP
script = document.createElement('script');
script.async = 'async';
script.src = url;

// Tidy up
script.onload = function () {
head.removeChild(script);
};
Expand Down

0 comments on commit f996d1e

Please sign in to comment.