|
revmoo posted:AJAX is a QA nightmare and makes debugging things a lot harder. Could you expand on these two things?
|
# ? Jun 1, 2015 22:46 |
|
|
# ? May 8, 2024 20:42 |
|
Data Graham posted:I tend to avoid full-page POSTs like the plague, and instead do everything with AJAX. I don't even use <form> tags anymore; I just serialize everything manually in JS. The Ajax/Form helpers are pretty nice in ASP.NET
|
# ? Jun 1, 2015 22:57 |
I'd guess it's because debugging a form post in a traditional page is like "View source, find the form action and/or submit button" "See what the form posts to, dig into server side code" Whereas for Ajax it's "Dig through DOM for button or element that triggers the post" "Rummage through opaque JavaScript (which may be inline or may be in any of several external files) to find the event handler attached to the element, because it's probably not just stuck on with an onclick()" "Find what the Ajax call is posting to, and figure out whether what you're debugging is server-side or client-side behavior" "Debug accordingly" Plus for frameworks like Django that double down on the "form" semantics, Ajax means you're tossing all that potential pre-built functionality aside. ...All that said, I still prefer Ajax conceptually because it seems better suited to MVC. I can do all my Ajax interactions and CRUD operations via JSON and have the page react smoothly, instead of having server-side logic embedded in a page or set up to spit out HTML pages or redirects. I know it's of course possible to do fully MVC-style ops with full-page POSTs, but it's technically possible to do anything; it just seems backward to me.
|
|
# ? Jun 1, 2015 23:01 |
|
Chrome debugging tips! Each XHR request has an "Initiator", which is the stack trace of the dispatch (just hover over it). This usually gives you somewhere to start - hopefully you'll recognise a file or class name as you click through the stack. Obviously you can't debug badly written JavaScript any more than you can debug badly written PHP. Code quality is paramount. Also if you have minified code, you can prittify it - and add breakpoints that do work, but clicking the "{}" icon: For me, AJAX forms are more effort than just plain Symfony forms, and this is why a lot of our forms don't use AJAX. Why? Because any submit (AJAX or otherwise) needs to use Symfony's Form system, which provides structure, validation, constraints and usually entity creation on the server-side. When we build all that, we basically get the HTML form for free, whereas adding AJAX to that requires extra work (events, what to do on validation errors, what to do on network errors, what to do on logout, etc). I'm trying to rectify this by allowing us to use jQuery.Validation in conjunction with a form error serializer on the server-side. This means besides actually dispatching the AJAX, there's a grand total of two extra method executions required (one on PHP, one on JavaScript) to get full form validation pumped back to the user, mapped to the appropriate fields. Where AJAX really becomes useful is where we have more than one form that needs to be submitted. Pretend for a moment I have a Document which needs to be filled out (form 1), but when I publish that document I need to provide a comment to go with it (form2). I could arse about with optional form fields and constraints so symfony handles all this as a one form, or I could just compile them both into a single request using JavaScript and submit both. Symfony can then read and handle both sets of data in the single request. If I'm just saving the document (not published), I only submit the document form. Yes, if you're not using symfony you could just hand-craft a single form, do empty checks on fields etc, but this approach actually helps to separate concerns (save & publish vs. just saving) and segregates chunks of crap from other crap. Personally, I prefer well implemented AJAX because it gives a much better user experience.. though a poorly implemented ajax submit is a nightmare. v1nce fucked around with this message at 00:58 on Jun 2, 2015 |
# ? Jun 2, 2015 00:50 |
|
Assuming the data you want to store between pages isn't sensitive information wouldn't it be easier to just use localstorage? It seems to be supported on everything these days. I am not a web developer.
|
# ? Jun 2, 2015 00:55 |
|
Sauer posted:Assuming the data you want to store between pages isn't sensitive information wouldn't it be easier to just use localstorage? It seems to be supported on everything these days.
|
# ? Jun 2, 2015 02:11 |
And a surprising lack of clear documentation about how localStorage objects from different sites are kept secure from one another.
|
|
# ? Jun 2, 2015 02:15 |
|
Sedro posted:Until you want to use more than a few MB. Then you run into browser specific size limits, inconsistent UIs nagging the user to increase the limit, no clear way to change those per-site limits... What is the use case where you would ever want to use a few MB locally?
|
# ? Jun 2, 2015 09:01 |
|
Data Graham posted:I tend to avoid full-page POSTs like the plague, and instead do everything with AJAX. I don't even use <form> tags anymore; I just serialize everything manually in JS. You should still use forms, even if you are serializing them. edit: what the hell, where did all these posts come from!
|
# ? Jun 2, 2015 09:50 |
Funking Giblet posted:You should still use forms, even if you are serializing them. Why is that? I ask because a lot of times I find myself creating tiny little fragments of interactivity on the fly, like maybe with one input field, that get fed into an AJAX endpoint and then the form gets destroyed or rebuilt, and there may be a dozen more on the page. It seems like the form semantics are just superfluous if I'm not going to be taking advantage of a traditional Submit button or an action attribute. E: Plus if I'm actively not going to be using a traditional submit, I then have to jump through hoops to prevent any buttons that ARE in the form from doing the default submit behavior, with "return false"s and preventDefaults and so on. Data Graham fucked around with this message at 11:55 on Jun 2, 2015 |
|
# ? Jun 2, 2015 11:51 |
|
Data Graham posted:Why is that? Screen readers and other accessibility aids might not handle it right.
|
# ? Jun 2, 2015 14:05 |
|
Munkeymon posted:Screen readers and other accessibility aids might not handle it right. Yup, AJAX is miserable for accessibility unless you're very careful about how you make your forms and whatever feedback that you provide. If there's ever a question about whether you have to make your site accessible or, God forbid, 508 compliant it's better to use forms and regular HTTP requests.
|
# ? Jun 2, 2015 14:11 |
|
Gmaz posted:What is the use case where you would ever want to use a few MB locally? Sites use localstorage to cache dynamic content, either to make the site more responsive or to make it available offline.
|
# ? Jun 2, 2015 16:30 |
I ran into it building a mobile app that had to store its entire state (including all content, which the user had to work through in a long list) locally in case the tablet crashed and had to come back up in the middle of a processing job. Sometimes that JSON object was 1mb+.
|
|
# ? Jun 2, 2015 16:49 |
|
Is there a limit on Ajax form inputs, say a text box? I, uh, set the "comments" section to varchar(max), but now I'm wondering if I should be a reasonable limit, like 4000-10000. The existing app we use is 2000 limit, but it's not enough, so the new app I'm building needs a bigger area - hence the MAX setting.
|
# ? Jun 2, 2015 22:04 |
|
Most web frameworks will have a configurable size limit for incoming requests. Any API should have it already appropriately set for expected payloads, but for your own form usage check what the default limits are. Nginx / Apache may also have a setting for it but have never had to configure there so unsure.
|
# ? Jun 2, 2015 23:50 |
|
Blinkz0rz posted:Yup, AJAX is miserable for accessibility unless you're very careful about how you make your forms and whatever feedback that you provide. As I said in my last post, badly implemented AJAX forms are a nightmare. Good ones are seamless. The problems usually come from everyone learning to use AJAX in a step-by-step manner; first they learn to submit, then they learn to get errors, and then they crowbar those errors into their forms in any way they'll fit. It's not until you have the entire cycle that things start to get implemented correctly. In our system that meant stopping everyone from reinventing the wheel, then having one approach which generates errors, and one approach which merges them back with the form they came from. WCAG, especially for screen readers, needs syntactically correct HTML and structure. Putting the inputs inside a single <form> element is definitely a thing, if you're targeting accessibility. kloa posted:Is there a limit on Ajax form inputs, say a text box? In PHP this is post_max_size, which defaults to 8Mb. That's quite the comment. You probably want to limit it to something more sensible before it ever reaches the DB. If it's then stored as a VarChar or Text, that's up to you. The difference is only a byte or so per field, iirc. There's also a field limit in PHP, which is max_input_vars. The default is usually 1000 fields. This is the stuff that will show up in _POST. If your form gets that retarded huge you can always push your data down one var as a JSON string, which isn't great, but should work. But if you're generating a form which is that huge you probably have other issues you need to look at, like usability.
|
# ? Jun 3, 2015 04:47 |
|
I wonder if anyone here can help: I saw a website a little while ago, I think it was linked from this thread but might be wrong, with an interesting hero section on their homepage. The background was a grid / collage of small images (I believe they were examples from the company's portfolio, but might be wrong), with individual images in the collage animating / changing to different images, seemingly at random. There was text or something in the foreground in front of the small animating images. I didn't bookmark it at the time and would like to see it again. Anyone know what I'm talking about?
|
# ? Jun 3, 2015 12:01 |
|
drat I've probably destroyed some screenreaders in the name of (what I thought was) slicker code.
|
# ? Jun 3, 2015 13:15 |
|
Kekekela posted:drat I've probably destroyed some screenreaders in the name of (what I thought was) slicker code. You and 99.9947% of web developers. Sadly, accessibility is not on most people's radars.
|
# ? Jun 3, 2015 14:50 |
|
Data Graham posted:Why is that? Why are you doing all that? You should use forms because the form should post to the end point no matter what. Scripts will break in production due to erroneous GTM usage, or bad CDNs or whatever. If you can live with your web app failing, that's fine, but the default behaviour should be baked into the website using as much of the traditional methods as possible. Use JavaScript to augment the experience. A lot of server side language support stuff like React rendering which means you should be able to accomplish complicated views with more traditional fallbacks.
|
# ? Jun 3, 2015 15:03 |
|
I need a way to show snippets of syntax-highlighted code in various languages in simple HTML if possible (or in javascript ). Anyone know what I can use for that? The goal is to have code snippets in a website which is otherwise just static HTML without having to manually format every dang example.
|
# ? Jun 4, 2015 23:40 |
|
java script: Prism or highlight.js Or if you hate yourself and others, there's tohtml.com. Prism looks the best, but kinda depends on which has the support for the languages you want to highlight.
|
# ? Jun 5, 2015 00:20 |
|
Using JavaScript, jQuery, AJAX, and/or JSON, is there a way to turn all the files in a directory into an array? I'd like to be able to pull all the images from a folder and have them display on a page and have this update whenever I decide certain images shouldn't be there and I can just remove them from the folder.
|
# ? Jun 5, 2015 03:09 |
|
Well, you've got two options, as I see it: 1. You AJAX request to your server and have it respond with a JSON list of files. 2. The script that generates the page provides JavaScript variables at render time, so it's statically loaded with the page. Option 1 can dynamically update at a given interval over AJAX, making repeat but small requests to your server. Your JavaScript can then update as appropriate. Option 2 makes the content only update when you refresh the page. This might be fine, depending on how "up to the minute" your data needs to be, or if your UI is some kind of JavaScript webapp. I'm a PHP man, so here's a dirty PHP solution (modified len from here): php:<? // images/index.php // Current directory $dir = opendir(__DIR__); // Get files $files = []; while ($file = readdir($dir)) { // Ignore parent directory references if (in_array($file, ['.', '..']) { continue; } // Ignore directory references if (is_dir($file)) { continue; } // Log all files $files[] = $file; } // Spit out JSON header('Content-type: application/json'); echo json_encode($files); ?> And some lovely jQuery (modified from here): code:
code:
|
# ? Jun 5, 2015 04:28 |
|
Option 3 is long polling and option 4 is websockets.
|
# ? Jun 5, 2015 14:48 |
|
Can anyone recommend some good reading about securing a REST API? I'd like to know what the modern thinking is around best practices, etc.
|
# ? Jun 6, 2015 00:11 |
|
Are domains from 1996 inherently valuable? I've got an unused domain I keep renewing just for the sake of 'real estate speculation' and I'm wondering if I should keep paying for it. It's not a common or short name or anything, but I could see it having some value in 5-10 years as .com domains continue to get bought up. EDIT: It's a PR4 if that helps, and that's after sitting completely idle for the last several years. revmoo fucked around with this message at 18:10 on Jun 8, 2015 |
# ? Jun 8, 2015 18:06 |
|
revmoo posted:Are domains from 1996 inherently valuable? I've got an unused domain I keep renewing just for the sake of 'real estate speculation' and I'm wondering if I should keep paying for it. It's not a common or short name or anything, but I could see it having some value in 5-10 years as .com domains continue to get bought up. My guess would be that no, there's nothing inherently valuable about an old domain. awesomechicagocarsforsale31.com is just as worthless now as it was in 1996.
|
# ? Jun 8, 2015 18:26 |
|
Alright, sanity check. I'm dealing with a weird CMS that outputs class names in the <body> tag that look like this:code:
|
# ? Jun 8, 2015 20:21 |
|
kedo posted:Alright, sanity check. I'm dealing with a weird CMS that outputs class names in the <body> tag that look like this: Obviously only works with CSS3 but: code:
|
# ? Jun 8, 2015 20:30 |
|
kedo posted:Alright, sanity check. I'm dealing with a weird CMS that outputs class names in the <body> tag that look like this: You should be able to use attribute selectors, like so: CSS code:
|
# ? Jun 8, 2015 20:31 |
|
Ah ha, that was what I was looking for. For some reason my brain couldn't compute attribute selectors being used with classes. Thanks! e: Depressing Box posted:EDIT: Beaten, but note that just using ^= can break if it isn't the first class on the element. The *= is actually exactly what I was looking for because there are an unsurprisingly massive number of classes in the body tag. The one I'm targeting is somewhere in the middle of a roughly 500 character string of nonsense. kedo fucked around with this message at 20:45 on Jun 8, 2015 |
# ? Jun 8, 2015 20:35 |
|
I need to make a way to deliver a small but dynamic playlist of proprietary videos to a likely small set of clients. The intention is for these videos to replay over and over, and for us to have the ability to add and remove videos from the playlist. Because of the nature of the playback (a small set of videos that occasionally changes), I want the client to download them once and then replay them without requesting the videos again. I suppose if I want to determine how these video files would get stored and replayed, a desktop app would offer me the most control. However, I'm trying to avoid that for a variety of reasons (worry about updating the desktop app for clients, we are currently a 100% web dev shop so we'd have to get up to speed on building desktop stuff, etc). Ideally, we would make a web app that does this, but I'm not entirely clear on how I can ensure that the videos will be cached and replayed. If I just set the appropriate cache headers on the video files, I assume I can dig into the browser cache to play the videos once they've already been downloaded, but are there limitations I should be aware of? Like, just how many bytes of video files will a modern browser be ok with caching? Will the cache be cleared unexpectedly? Keep in mind I will have control over the client setup, and can dictate things like 'use this browser with these settings', etc.
|
# ? Jun 9, 2015 16:45 |
|
What are some good services for sending notifications to users via email or SMS? Everything seems to be focused on sending out mobile device notifications but I need something a bit more traditional for this web app I'm working on. Amazon has its "SNS" service but I've just started reading the API docs and so I'm not yet sure if it's a feasible solution.
|
# ? Jun 10, 2015 06:01 |
|
Amazon also has SES which is their Simple Email Service. It's specifically designed for bulk email sending.
|
# ? Jun 10, 2015 11:31 |
|
Anyone have any recommended reading materials for asp web dev? New job is entirely web based when all my experience is desktop applications I understand the concepts of get/post but having some troubles implementing what I think should be simple things, like populating 2 grids based off a selection in one grid, while retaining its selection. But if you go to like any car selling website its basically the same thing; pick a Manufacturer, populate a Model drop down, populate a Trim drop down etc. Drop downs and grids are obviously different, but the principle should be the same... Sab669 fucked around with this message at 18:46 on Jun 12, 2015 |
# ? Jun 12, 2015 14:13 |
|
Sab669 posted:Anyone have any recommended reading materials for asp web dev? New job is entirely web based when all my experience is desktop applications I have basically forgone it's use and have janked together my own system using HTML tables or lists (depending) that are populated from the model which contains various necessary collections. This is all made easier as I'm using an orm to write and hydrate objects to/from the database. Personally I've had nothing but problems with gridview.
|
# ? Jun 13, 2015 01:24 |
|
Any tips on Mandarin / Cantonese web development? Anything different about registering a domain with Chinese characters? Should I pick a domain with just Chinese numbers? (apparently this is a thing) Anything to watch out for with font rendering? And of course the one I'm dreading the most: ensuring accessibility for users in mainland China...
|
# ? Jun 13, 2015 15:07 |
|
|
# ? May 8, 2024 20:42 |
|
AuxPriest posted:By grid do you mean gridview? Using ASP DataGrids, not GridViews
|
# ? Jun 13, 2015 23:50 |