Originally posted by thunderlizard
View Post
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Who's done the least work today?
Collapse
X
-
-
Comment
-
I had to spend Mon-Thurs working at home to get some documents finished.
Came in today, director signed off this weeks time and signed 2 blank t/s for the next fortnight as he is away in the States working.
If I didnt win this week, then the next 2 weeks: no contest!
PZZComment
-
This morning started to be 'one of those days', but got better just before noon and I've made progress for the rest of the day.
However, it's taken me all week to manage to put two rows into one of the tables in a database.How did this happen? Who's to blame? Well certainly there are those more responsible than others, and they will be held accountable, but again truth be told, if you're looking for the guilty, you need only look into a mirror.
Follow me on Twitter - LinkedIn Profile - The HAB blog - New Blog: Mad Cameron
Xeno points: +5 - Asperger rating: 36 - Paranoid Schizophrenic rating: 44%
"We hang the petty thieves and appoint the great ones to high office" - AesopComment
-
Giving up on the image display
It would have been nice, but not really necessary. The submit button takes them to a page that displays what they've just entered anyway. And if users don't know what image they're uploading, that's their lookout!Comment
-
Originally posted by thunderlizard View PostIt would have been nice, but not really necessary. The submit button takes them to a page that displays what they've just entered anyway. And if users don't know what image they're uploading, that's their lookout!
Originally posted by thunderlizard View PostProblem is basically this: FileUpload control doesn't work in an UpdatePanel, so I'd have to wait for a full page postback so my one-step user-enters-details-and-saves-them idea would be lost.
However, XHR will only do requests where the content-type of the form (which for some obscure reason is defined by the enctype attribute) is application/x-www-form-urlencoded. Although this is fine for most things, it doesn't allow for the upload of files. That requires the content-type multipart/form-data, and XHR cannot deal with that. (Linky to the spec, FWIW.)
Originally posted by thunderlizard View PostBrand-spanking new AsyncFileUpload has the opposite problem: it uploads the image quick as you like but doesn't trigger a postback so I can't show it on screen.
Given that XHR can't upload files we are left with one obvious fact: the browser can upload files. Therefore we make use of the browser. What we do - or, what the library does for us - is to create an iframe, hide it by positioning it off-window, assign a name to it, set the target attribute of the form to that name, assign an onload handler to the iframe, and call the form's submit method. From that point on the browser just does what it does when making a normal request-response cycle; and you'll see activity in the usual places, like throbbers and status bars.
When the iframe then loads the response to the file upload, the onload handler kicks in. When using a library, this is the point where the response is packaged up in some way and sent to your "oncomplete" (or whatever it's called) handler.
However, you now face a number of deviations from the normal situation upon receiving the response to an Ajax request:
- The XHR object's responseText and responseXML properties aren't available, as there never was an XHR object in the first place;
- If the server sent the response as text/html, and it wasn't an HTML page, the browser will probably wrap some <pre></pre> tags around it for rendering purposes (not all browsers do this);
- If the server sent the response as XML and it wasn't well-formed, the iframe might contain an XHTML error message from the browser's XML parser (Firefox does this);
- If the server sent the response as XML and it was well-formed, the iframe might contain a bunch of not-very-well-formed HTML and JavaScript that, if seen by the user, would be a pretty-printed interactive rendering of the XML (IE does this);
- If the server sent the response as text/json, the browser will probably pop up a dialog asking the user if they want to save the file to disk, as browsers don't display that content type;
- If the server sent the response as text/plain, and you wanted XML or JSON or HTML, you need to grab the plain text and find a way to parse it yourself.
- ...and other possible pitfalls.
Of course, you may also have to deal with the way your library attempts to deal with these situations: it might make things better, or worse, or just different
See what I mean about hacks and leaky abstractions?
Still, with that basic summary of the background to it all, a few minutes with a debugger on your own code combined with an HTTP debugger like Fiddler or Charles should see you clear to getting things working. Just remember to check across as many different browsers as you can
P.S. It can be done; I've done it. I was using YUI with Symfony on the server, but those details are irrelevant: whatever you're using is doing it that way.Comment
-
First week on a new job and I did pretty much nothing, what do they expect you to do when they give you a machine with 1 gig and expect you to run websphere on it?Comment
-
Nick, you never fail to impress.
The workaround that probably would have worked would have been to use a client-side event on the uploader to populate an image via Javascript. More effort that I want to spend on a nice-to-have. Ever get the feeling you're writing DailyWTF-grade code that would be avoidable if only you knew the proper way? well maybe you don't but it's a constant worry for me.Comment
-
Originally posted by Jeebo72 View PostI've wrote two SQL statements (1 liners), gone to the pub for 3 hours, and that's about it ... can you beat?
PS You must be getting paid to do nowt! ;-)Cats are evil.Comment
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Comment