GithubHelp home page GithubHelp logo

xhrSend about jessie HOT 15 CLOSED

web-bert avatar web-bert commented on August 24, 2024
xhrSend

from jessie.

Comments (15)

iancrowther avatar iancrowther commented on August 24, 2024

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.

david-mark avatar david-mark commented on August 24, 2024

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.

iancrowther avatar iancrowther commented on August 24, 2024

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.

david-mark avatar david-mark commented on August 24, 2024

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.

david-mark avatar david-mark commented on August 24, 2024

Also, if we are going to call the method to create XHR objects "ajax", then perhaps "ajaxGet", "ajaxPost", etc.

from jessie.

adamsilver avatar adamsilver commented on August 24, 2024

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.

david-mark avatar david-mark commented on August 24, 2024

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.

adamsilver avatar adamsilver commented on August 24, 2024

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.

web-bert avatar web-bert commented on August 24, 2024

So I think ajax should be updated to handle the differences between 'data' for GET and POST?

from jessie.

david-mark avatar david-mark commented on August 24, 2024

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.

web-bert avatar web-bert commented on August 24, 2024

ajaxGet and ajaxPost?

from jessie.

david-mark avatar david-mark commented on August 24, 2024

Hadn't thought about it, but we probably need names that convey the two steps (create and send request).

from jessie.

adamsilver avatar adamsilver commented on August 24, 2024

#71

Have kept ajax and xhrSend for the moment but will remove ASAP.

from jessie.

david-mark avatar david-mark commented on August 24, 2024

At a glance, it looks like this issue can be closed.

Thanks for all of your help! :)

from jessie.

adamsilver avatar adamsilver commented on August 24, 2024

No problem.

from jessie.

Related Issues (20)

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.