Comments (15)
I came across the very same issue yesterday, I ended up writing my own helper to build up the url query string for "GET". Your welcome to have the code, but it's super simple.
xhrSend as it is, is a little confusing and needs to be reviewed, maybe some more details comments.
The question as I see it is, should the function be able to handle the logic of "GET" plus data, or should we the developers understand how xhr works and use xhrSend as a simple helper, eg dont try to send a "GET" with data as this is not to spec. Im wary of putting too much logic into jessie!
Let me know your thoughts as im working on this bit of code now and can plan some changes.
from jessie.
If it is only a GET at this time, then name is a misnomer. Let's start with xhrGet and xhrPost. The GET could take a data argument, but only as a convenience (the URI argument can include parameters for such "data"). If the URI has parameters and data is passed to GET, the developer is likely confused and an exception should be thrown (as part of "scaffolding" section). Or perhaps we leave it off at this level.
On posts, the data argument will be used most of the time, but does not preclude the inclusion of parameters on the URI.
I think GET with no data argument and POST with optional (but virtually always used) data argument. Should be able to take an Object object reference or an already encoded ampersand-delimited string (test for the string, not the object). Can always build up from there (e.g. with a constructor).
Ultimately will need PUT (rarely used) and DELETE (even more rarely used) for completeness. Some "CRUD" systems use PUT for updates and POST for creates. I suppose there are server-side frameworks that make use of this distinction.
Wrappers for GET and POST that process JSON results will be a good step up from these. The option to cancel an in-process request (and start a new one) is often needed as well, but I'd probably wait and do that at the constructor level.
from jessie.
Good call @CinSoft. Seems like a good plan to me.
I'm assuming that the jessie builder would allow users to grab jessie.ajax with one or more dependancies.
from jessie.
I'm not sure how the builder is dealing with dependencies at the moment. Should throw an exception if one or more fails to resolve. The client side should try to avoid that with validation before calling on the node stuff.
One other thing, an option to prevent caching (see Requester in My Library) is a must at some point. Allowing caching is dicey due to (of course) old versions of Internet Explorer that cache XHR GET requests forever.
from jessie.
Also, if we are going to call the method to create XHR objects "ajax", then perhaps "ajaxGet", "ajaxPost", etc.
from jessie.
We have createxhr for that!
On Tuesday, August 21, 2012, David Mark wrote:
Also, if we are going to call the method to create XHR objects "ajax",
then perhaps "ajaxGet", "ajaxPost", etc.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/66#issuecomment-7897026.
from jessie.
Oh, I thought "ajax" was the function that created XHR objects. I see now that it is a combination of create and send.
from jessie.
Yes. Exactly.
On Wednesday, August 22, 2012, David Mark wrote:
Oh, I thought "ajax" was the function that created XHR objects. I see now
that it is a combination of create and send.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/66#issuecomment-7933749.
from jessie.
So I think ajax should be updated to handle the differences between 'data' for GET and POST?
from jessie.
I think it needs to be split like the other one at this level. Higher level functions can do double duty to provide a "simplified" interface.
from jessie.
ajaxGet and ajaxPost?
from jessie.
Hadn't thought about it, but we probably need names that convey the two steps (create and send request).
from jessie.
Have kept ajax and xhrSend for the moment but will remove ASAP.
from jessie.
At a glance, it looks like this issue can be closed.
Thanks for all of your help! :)
from jessie.
No problem.
from jessie.
Related Issues (20)
- playAudio and playAudio loop
- Add viewport meta
- Fix ui enhance bug
- Get David to change to org so can change the name/add more collaborators etc
- Fix download button appearance iphone etc
- Tidy builder: specifically get rid of the word "jessie" out of lib - make more flat
- Fixup attachListener and bind etc
- Cover document
- Change meta.js to meta.json HOT 1
- Tonight HOT 1
- Create isOnline
- Cover the document function
- Document bumping
- Setup .jshintrc
- Setup .jscsrc
- Create user guides
- Asymmetry in add/removeClass
- Should have wrapper for Array.prototype.indexOf
- Remove all tabs
- Switch to CommonJS and ditch builder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jessie.