Ajax Uploading with Symfony's HTTP Foundation - ajax

I used symfony's HTTTP foundation as a part of my own project. But I can't found the way for ajax uploading with it.
How to upload file in Symfony's HTTP Foundation with ajax? Is there any plugin or addons or another way?

You're probably using a component like jQuery Upload, Uploadify, etc... You might only have any trouble with the uploading process described in here (http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html) if you are doing it behind a firewall (restrict area, e.g.).
The whole problem is that the session id (usually stored in cookie) is not present with those uploading component requests. It's do a Flash's limitation. Use the procedure described in this article ( http://www.elao.com/blog/symfony-2/symfony-2-loading-session-from-query-param.html ) and you should be fine.

Related

Fine-uploader with standard form

Is there somewhere or does someone know how to use fine-uploader with a basic form, no ajax? I've attempted to use the standard method with Mura CMS and 12 hours later Mura's internal permissions have beaten me.
This is from the perspective of a Fine Uploader developer, not a user or developer of Mura CMS (which I have no experience with):
Fine Uploader does not have a way -- currently -- to turn AJAX requests off and use a form submit manually. All of this is done internally as Fine Uploader progressively enhances itself as browser features are supported.
If your framework does not allow AJAX requests to be made to it one workaround would be to setup a separate server on another domain just to handle uploads. You would have to enable CORs and setup access-control rules, but this would then allow you to make AJAX requests to upload.
The real question is why does your CMS not allow AJAX and how because that might give clues as to another workaround.

100% Ajax Websites

I have been looking at Hulu's new website and I am very impressed from a developer's standpoint (as well as a designer's).
I have found that, unless you switch between http/https, you are served content entirely from json requests. That is a HUGE feat to have this level of ajax while maintaining browse back button support as well as allowing each url to be visited directly.
I want to create a website like this as a learning experience. Is there any type of framework out there that can give me this kind of support?
I was thinking I could...
leverage jQuery
use clientside MVVM frameworks like KnockoutJS?
use ASP.NET MVC content negotiation to serve html or json determined by an accept header.
using the same codebase.
use the same template for client side and server side rendering
provide ways to update pagetitle/meta tags/etc.
Ajax forms/widgets/etc would still be used, by I am thinking about page level ajax using json and client side templates.
What do you think? Any frameworks out there? Any patterns I could follow?
It is always best to first build a website without AJAX support, then add AJAX on top of that. Doing this means that:
users without javascript can already access your website
users can already visit any URL directly.
Adding AJAX support can be accomplished by various javascript libraries. So that you can render json content, you will want to look at javascript templating. You will want to use javascript templating even on your server side for when you add AJAX support (file extension .ejs). This will probably require some appropriate libraries to run javascript on the server.
When you add AJAX support, you will want to use the "History.js" library for browser back/forward/history support.
Make no mistake. This is a HUGE project (unless your website only has a few pages). So it is going to take a LONG time to add all the AJAX support to the best possible standard.
to answer your bullet point about using the same template server side as well as client side: check outdust. It was originally developed by akdubya, but has since been adopted and enhanced by linkedin. They use it to render templates on their mobile app client side. Personally I've used it on the server side and it works great.

What methods are there for querying a database from a webpage?

I am fairly new to web development, and I am currently creating a mobile web app with PhoneGap. That is to say, it's done entirely in html and associated technologies, which the app then links up properly to function within whatever OS the device is running.
Portions of this app require me to retrieve data from a database on a remote server. This is an entirely new thing to me, having never done any programming involving networks/connections.
I was recommended to use AJAX for this purpose, but I'd like to be certain I'm making an informed choice. What other options are there for an HTML page to retrieve data from a remote server?
there is no other choice you will have to use ajax ( using jquery for exqmple ) to get your data back from the server ..
the best way ( from my point of view ) is to make sure that your data is retrieved as json or jsonp so that you can handle it easily within your app.
and if you do use jquery ajax remember to configure it to allow external ajax request.

Javascript file upload mechanism

I need for users to upload files (mostly images) without leaving the current webpage. What's the best tool, library or mechanism for doing this? I'm using the latest jQuery and Spring webmvc (with JSP), so if there's already a mechanism within them then that's ideal.
It would also be really great to have some kind of progress bar. Does that mean it requires coordination with the server to read the progress (where Spring would have to come into play)? Or is there a mechanism within JavaScript for this?
You should check out Plupload.
Plupload offers a cross-browser
JavaScript File uploading API that
handles multiple file uploads,
client-side progress meters, type
filtering and even client-side image
resizing and drag-and-drop from the
desktop. It achieves all of this by
providing backends for Flash,
Silverlight, Google Gears, HTML5 and
Browserplus and picking the most
capable available option.
Its really neat! Here's a link to some of their Demos...
http://www.plupload.com/example_jquery_ui.php
... and a screenshot of the jQuery UI queue widget (it has a progress bar!):
I hope this helps.
Hristo
I use uploadify pretty regularly: http://www.uploadify.com/
However it does use flash for the upload mechanism and as a result may create some issues if the user is authenticated.
You should use AJAX on the client side
http://www.webtoolkit.info/ajax-file-upload.html This tutorial covers all client side.
Om the server side
This tutorlal covers most of this issue:
http://www.ioncannon.net/programming/975/spring-3-file-upload-example/
Yopu can use jquery as well or any other JS framework.
But the mist important thing is the fact You need to remember that your tag on client side should have.
enctype='multipart/form-data'
property. it means that your request contains muultipart data.
Uploadify does that trick > http://www.uploadify.com/
All samples are php but you should be able to convert it to your platform.

Ajax using Prototype.js in OFBiz

I need to make an Ajax call inside OFBiz framework using prototype.js. I am doing that from a .ftl file. I am confused about how to handle the server side - through Java event or Java service? What is the best practice? And also I am having problems making the framework recognize the prototype.js file. There is some issue with the path name in the script tag. It has to be some peculiar naming as per OFBiz framework standards.
I searched Google but I only found links on how to use prototype but none on the combination of prototype + OFBiz. If anybody has done anything in OFBiz like this, please help.
The server process the AJAX request just like any other request. It may contain an event or not, and the response your js function will get is the HTML output ( if the response is a view ). If you want to use JSON, you must create an event with type="jsonservice" ( and you must include the jsonservice handler in your controller file ). This way you can send and receive data structures using AJAX.

Resources