|
Is there a JavaScript library that duplicates the functionality of jquery's .ajax function but without everything else?
|
# ? Jun 27, 2012 11:34 |
|
|
# ? Jun 5, 2024 08:30 |
|
Well, I don't actually know anything about Zepto and it is not strictly just .ajax(), but it is a "minimalist JavaScript library for modern browsers with a largely jQuery-compatible API." http://zeptojs.com/ Like I said, I don't know anything about it, just stumbled on it when reading backbone.js documentation.
|
# ? Jun 27, 2012 11:41 |
|
code:
API.ajax(url, options); * options.method - defaults to "get" * options.timeout - defaults to 30 seconds * options.complete * options.success * options.headers * options.data * options.fail API.ajax('http://someUrl',{success:function(xhr){alert(xhr.responseText);}});
|
# ? Jun 27, 2012 12:09 |
|
Wheany posted:Watch this video (java script: The Good Parts). It's a pesentation by Douglas Crockford at Google Tech Talks. Thanks, I use st2 and have been using the linting package, it gives me realtime lint warnings and errors.
|
# ? Jun 27, 2012 13:46 |
|
Wheany posted:Well, I don't actually know anything about Zepto and it is not strictly just .ajax(), but it is a "minimalist JavaScript library for modern browsers with a largely jQuery-compatible API." Yeah I use zepto in my mobile apps, but I just don't need that darn selector doohickey!
|
# ? Jun 27, 2012 15:06 |
|
https://github.com/joehewitt/ajax
|
# ? Jun 27, 2012 15:10 |
|
Kallikrates posted:Where is a good source for picking up best practices etc for writing javascript for websites? Some things to be aware of / do: Namespace your code. Always. Learn about the 'module pattern', use it where it makes sense Learn about custom events and writing event driven code, use it where it makes sense As far as best practices, combine and minify your scripts when you hit production, and unless there is a reason not to, load your scripts at the end of the BODY. Seconding reading / watching Crockford stuff. He definitely has a "my way is the only way!!" thing going on, but overall he is a great teacher of the JavaScript. John Resig of jQuery fame has a book coming out soon (not sure of the expected date) that I got a review copy of, and that is / will be an awesome resource.
|
# ? Jun 27, 2012 17:52 |
|
Funking Giblet posted:It's been changed a few times in the last number of releases, and it's been broken a few times, so it's neither reliable nor tested. (Not to mention the confusion after they change how attr worked, how reliable was that either?) If anything that's an argument for why you shouldn't try to do it yourself. If jQuery can't get it right without a few iterations then it's unlikely that a lone developer can.
|
# ? Jun 27, 2012 19:21 |
|
Funking Giblet posted:It's been changed a few times in the last number of releases, and it's been broken a few times, so it's neither reliable nor tested. AJAX? How so?
|
# ? Jun 27, 2012 19:29 |
|
Gordon Cole posted:If anything that's an argument for why you shouldn't try to do it yourself. If jQuery can't get it right without a few iterations then it's unlikely that a lone developer can. That's you putting jQuery on a pedestal. It's a case of understanding what you are doing. I know what attributes are vs properties, I gather most people don't, hence the usage of attr when direct properties would do the job instead of the crap that goes on in that method. ie: .attr("checked",ehwhatTheHellDoIset) vs. el.checked = true I wonder how many people changed to prop, then to attr, without knowing what the hell was going on. (bear in mind, el.checked = true has worked since IE4) quote:AJAX? How so? http://blog.jquery.com/2011/01/31/jquery-15-released/ Search "Ajax rewrite"
|
# ? Jun 28, 2012 00:02 |
|
There was an internal rewrite, with no API break, but instead, provides more consistency for random browser bugs. How does that support your argument?
|
# ? Jun 28, 2012 00:07 |
|
Suspicious Dish posted:There was an internal rewrite, with no API break, but instead, provides more consistency for random browser bugs. How does that support your argument? So they broke one part of their API doing a rewrite, but not another, and that's the what you are standing behind? And they changed the public interface as it returns something different. I've never ever had a break doing it my way. That's my argument. They committed a cardinal sin in rewriting public APIs. Have you much experience working with JavaScript or APIs in general? The JavaScript community seems quite bohemian in their ways, I guess it's because of the lower barrier to entry. Again, I'm not saying you should abandon JQuery, but god drat if people just stand behind everything they do even when they are quite cavalier when their poo poo breaks. THIS STUFF IS EASY TO LEARN, LEARN IT. Funking Giblet fucked around with this message at 00:27 on Jun 28, 2012 |
# ? Jun 28, 2012 00:22 |
|
What part of their public API did they break? They also changed it from returning a real XHR to returning a jqXHR - the latter is a dummy object that papers over the real XHR, and all the properties that jQuery said you were allowed to touch were still there. I do not understand how that's an API break. I'm behind good software engineering practices. I'm not standing by them unilaterally - I said that you can also use MooTools or Dojo or something. I'm simply trying to understand how they broke API at all.
|
# ? Jun 28, 2012 00:36 |
|
Suspicious Dish posted:What part of their public API did they break? They also changed it from returning a real XHR to returning a jqXHR - the latter is a dummy object that papers over the real XHR, and all the properties that jQuery said you were allowed to touch were still there. I do not understand how that's an API break. So if you're behind good software engineering practices, how do you explain the attr debacle? I said Ajax was changed, not broken, the attr() is what broke recently. (1.6.1 I believe).
|
# ? Jun 28, 2012 01:02 |
|
Funking Giblet posted:So if you're behind good software engineering practices, how do you explain the attr debacle? I said Ajax was changed, not broken, the attr() is what broke recently. (1.6.1 I believe). Did jQuery steal your girl or something? Crazy idea: if you coded to jQuery 1.5.2 (or 1.3.6, or 1.6.1, or.... ) and don't want those evil jQuery guys breaking your poo poo *ever*, just include jQuery 1.5.2 (or 1.3.6, or 1.6.1, or....) on your page instead of 1.7 (or 1.8, or...) on your page. Are they flawless golden gods? No. But jQuery by and large has been rock solid, it's public face has been incredibly consistent for a project with it's scope, and they do a very good job about communicating upcoming changes. If you are only using a single function or method, yeah, 33k is a big download, but 33k off a CDN verus your code that hasn't been reviewed, tested, or vetted anywhere near as much as jQuery might be worth it.
|
# ? Jun 28, 2012 01:47 |
|
Funking Giblet posted:So they broke one part of their API doing a rewrite, but not another, and that's the what you are standing behind? And they changed the public interface as it returns something different. I've never ever had a break doing it my way. That's my argument. They committed a cardinal sin in rewriting public APIs. Have you much experience working with JavaScript or APIs in general? The JavaScript community seems quite bohemian in their ways, I guess it's because of the lower barrier to entry. Again, I'm not saying you should abandon JQuery, but god drat if people just stand behind everything they do even when they are quite cavalier when their poo poo breaks. THIS STUFF IS EASY TO LEARN, LEARN IT. Not using a library because they might change their API at some point is just silly. If you're really too lazy to update your code as the API changes, just don't update the library. Here's my argument in more detail. If I decide to use jQuery to do my ajax call, I can google "jquery ajax", click the first link to get to the documentation and have everything I need to get up and running in less than five minutes. I think it's reasonable to assume that the majority of modern web apps are using jQuery in production, so I can be reasonably sure that it's reliable enough for my own uses. If I decide to write my own implementation, I can google "javascript ajax" and learn how to use the browser's API. Fortunately I'll know to avoid w3schools (the first result), but others might not know to do that. I can do some research to learn about cross-browser compatibility issues and write my own little ajax library. In the end I've spent probably about an hour or two to create something that's almost certainly not as flexible as jQuery, and when a bug causes it to break a few months down the road I'll have to go in and fix it myself. The tradeoffs just don't make sense. The time spent updating code to match new APIs is going to be significantly less than writing your own libraries, dealing with lovely browser APIs and debugging cross-browser compatibility issues.
|
# ? Jun 28, 2012 01:48 |
|
Funking Giblet posted:I said Ajax was changed, not broken Funking Giblet posted:It's been changed a few times in the last number of releases, and it's been broken a few times, so it's neither reliable nor tested. Feel free to move the goalposts. The attr/prop split is a good cleanup.
|
# ? Jun 28, 2012 02:48 |
I want to let the user save their game but I'm not sure of what would be the best way to do this. I have three things which need to be saved: The current level name, a list of objects which persist between levels, and a list of objects which are permanently removed. Currently I'm saving this to a cookie but even with just a small amount of data I'm already over 1kb. I'm afraid that eventually I'll reach some cookie size limit and this will break it. I've done pretty much everything I can to make the save data as concise as possible. Is there some other method I can use for saving/loading? Saving a file on the server is out of the question.
|
|
# ? Jun 28, 2012 16:35 |
|
Manslaughter posted:I want to let the user save their game but I'm not sure of what would be the best way to do this. If you can't store to a server, you have few options. One is cookies... but the good news is, you can store 4k per cookie, and store ~30 cookies per domain. So in theory, you can do a bunch of storage that way. Until they clear their cache... The other way is to use "Web Storage" (http://dev.w3.org/html5/webstorage/) but then you'll have to figure out your needs as far as browser support. IIRC, it's IE 8+ and pretty much all other browsers.
|
# ? Jun 28, 2012 17:01 |
|
I think localStorage is probably the most widely-supported option.JavaScript code:
|
# ? Jun 28, 2012 17:03 |
|
There's a few shims for localStorage that use cookies or Flash LocalSharedObjects.
|
# ? Jun 28, 2012 17:49 |
That works perfectly and is easier than cookies even. Thanks!
|
|
# ? Jun 28, 2012 21:09 |
|
Lumpy posted:Did jQuery steal your girl or something? I guess most people will be stuck at 1.9 in the future for a long time anyway!
|
# ? Jul 2, 2012 12:31 |
|
Funking Giblet posted:I guess most people will be stuck at 1.9 in the future for a long time anyway! The price of progress!
|
# ? Jul 2, 2012 13:29 |
|
I have a checkbox on this form setup so that when it is clicked it calls a function that checks to see if the relevant fields have been properly filled out right now it works but it only works once so if someone checks the box then unchecks it and presses submit they then have to fill out all of the fields instead of just the ones that apply to them. So what I want to do is if the box is checked then all fields are required but if it isn't then only some of the fields are required What im trying to do is when you click on this checkbox then it calls the function to check if the required fields have been filled out. Uncaught TypeError: undefined is not a function :223 (anonymous function) The Checkbox in question code:
code:
Black Noise fucked around with this message at 15:06 on Jul 5, 2012 |
# ? Jul 5, 2012 14:21 |
|
From the error message it sounds like ValidationCheckbox is undefined. If you put a breakpoint on that line, what does it say is the value of Spry.Widget.ValidationCheckbox?
|
# ? Jul 5, 2012 14:56 |
|
I fixed the function undefined issue, now I'm trying to make the checkbox that calls the function work more like a light switch for the field validation
Black Noise fucked around with this message at 16:06 on Jul 5, 2012 |
# ? Jul 5, 2012 15:01 |
|
Is anyone familiar with google maps api using javascript? I am specifically trying to use the geocoder api and my code is as follows:code:
|
# ? Jul 6, 2012 05:48 |
|
I'm using Ruby on Rails and Backbone, and I'm writing the js in Coffeescript. I'm having a problem in my view, where I get the following error: code:
code:
code:
code:
I'm just starting out with Coffesscript and Backbone, so I don't really know what I'm doing.
|
# ? Jul 6, 2012 07:15 |
|
Is the template actually "listings/major_category_selet" or is it suppose to be "listings/major_category_select" ?
|
# ? Jul 6, 2012 07:23 |
|
The problem is what it says, that the template property is being used as a function but it isn't one. It looks like the most likely cause is a typo: "listings/major_category_selet" is probably supposed to be "listings/major_category_select". That typo would cause the template property to be undefined, which is not a function. The reason it doesn't complain when you put the arrow in is that you're making the property into a function, so it can be called, but it doesn't render because the function doesn't do what's expected (return some HTML, I assume).
|
# ? Jul 6, 2012 07:23 |
|
Wheany posted:Watch this video (java script: The Good Parts). It's a presentation by Douglas Crockford at Google Tech Talks. I'm watching this right now and I'm interested in how he explained Javascript's semi-colon insertion. That's how it works? I mean, I doubt he's lying but drat. Do I need to worry about that? My js rarely gets huge, but it does kind of worry me in the long run. Is there much of a performance hit between writing semis and leaving them out in huge projects?
|
# ? Jul 6, 2012 14:10 |
|
biochemist posted:I'm watching this right now and I'm interested in how he explained Javascript's semi-colon insertion. That's how it works? I mean, I doubt he's lying but drat. You should put your own semicolons in, but not for any real concern about performance. Putting semicolons in explicitly makes it clear "what you meant" to others (and to yourself in 3 months when you revisit your code) and also avoids some functional "gotchas" where letting the interpreter put them in for you might not give you what you expect / want.
|
# ? Jul 6, 2012 14:49 |
|
I've never run into any problems with javascript's rules about automatic semicolon insertion. However the coding style I use never puts the return statement on a different line so I don't run into weird semicolon gotchas. Here's the thing, unless you like putting every single thing on its own line you will never run into problems with javascript regarding semi-colons. Use semi-colons if you prefer it, or don't use them if you hate them. The only time I will ever space out code by adding a new line is when I'm chaining statements together, and that is not affected by the rules of ASI. If you want to read the rules for semi-colon insertion it's here: http://bclary.com/2004/11/07/#a-7.9.1 If you read the next section about examples, you have to be a pretty bad developer to write in some of the ways that will create these gotchas. I don't bother with semicolons but that's more of a preference than anything else.
|
# ? Jul 6, 2012 16:12 |
|
That's third edition. Please read the ES5 spec: http://es5.github.com/#x7.9
|
# ? Jul 6, 2012 17:48 |
|
Bookmark updated. But still, it's the same thing.
|
# ? Jul 6, 2012 18:30 |
|
Strong Sauce posted:Is the template actually "listings/major_category_selet" or is it suppose to be "listings/major_category_select" ? FACK. Thanks, guys.
|
# ? Jul 6, 2012 20:32 |
|
Lumpy posted:You should put your own semicolons in, but not for any real concern about performance. Putting semicolons in explicitly makes it clear "what you meant" to others (and to yourself in 3 months when you revisit your code) and also avoids some functional "gotchas" where letting the interpreter put them in for you might not give you what you expect / want. Non-use of semi-colons or not using braces is only of my coding pet peeves with c-style languages. I've tried to contribute to some opensource (mostly jQuery plugins that I use) when I can, especially ones with promise that fall victim to poor coding standards. Only to have the changes rejected and comments deleted when I raise concerns.
|
# ? Jul 6, 2012 21:34 |
|
If you're contributing to another project, follow the existing standards. If you don't like them? Too bad. You're not the maintainer. Go fork the project if you really want to. No maintainer ever likes seeing a whitespace/code-style fix on its own, or a large amount of them compounded with some other fix.
|
# ? Jul 6, 2012 21:43 |
|
|
# ? Jun 5, 2024 08:30 |
|
I'm building a class on top of JQuery's $.ajax class. My JSON has a response code that determines which function to call back. code:
|
# ? Jul 7, 2012 19:53 |