How to use ajax post on webmatrix webimage helper especially in webimage.getImagerequest() - webmatrix

I've been trying to use the webimage helper in webmatrix to upload an image using ajax but its not clear to me how i can pass data to the webimage.getImageRequest("Image") method from the ajax post.This helper seems to retrieve its file upload data from the browser when the page form is posted.For me, i dont want to refresh the form...I just want ajax to handle process

The issue here isn't the WebHelper - uploaded files are not posted with ajax requests:
How can I upload files asynchronously?
So you're probably getting a file name, but no content. That thread above shows a few work arounds that should work fine with the WebHelper. I've also had pretty good luck with uploadify:
http://www.uploadify.com/
Happy Coding!

Related

Dropzone.js Don't Show Result After Upload

Im trying to upload multiple files by dropzone.js in my MVC Project. The files upload successfully but the problem: after upload files, the page reset and i cant see the results. I have almost searched all the related subjects in this site and the other examples. I see people want to learn how they can refresh page :) but i want to stop page after upload. The results preview disappear quickly. Thanks for any help.
After hours, i see its not about dropzone, its about mvc. Because of post data in mvc, if you save a file, modelstate change, then automatically redirect the previous action/view and the results disappear. So it seems like a page refresh. Anyway, its suggested to use PRG instead of POST. Or redirect another GET action after successfully upload.

WordPress image upload Using ajax?

I'm making front-end profiler in WordPress. I want to upload user photo from front-end. My entire profile is on WordPress ajax. I simply want to upload photo to wp-content/uploads/.. but from front using ajax. I want two things:
1) Media hook
2) File to post through ajax
Can anyone help me a little. I'm really stuck in this place.
First:
For Wordpress new Media Uploader you should look to this tutorial.
Second:
To handle file uploads in Wordpress, you can use the function wp_handle_upload
Note:
You can use Form Data API to upload files with ajax but it may not work with older browsers. Instead you can do file uploads with iframe.

In Rails how do I use ajax? where do I put my Ajax code?

How do I get data from the database, without refreshing the page?
I dont even know where to start...
In Rails you will need to implement a page that pulls data from the DB and shows the data in whatever format you prefer, plaintext/json/xml. There's no asynchronous stuff in this part.
Ajax will be happening in frontend, the javascript part, that asynchronous connects to the webpage that you made above. jQuery's $.ajax will save you a lot of time.
You'll need to make your AJAX call from either an onload.js or a page specific js file (example.js). You'll then need to run a $.get or $.post call to the URL of the data.
Here is a pretty detailed tutorial: http://www.tutorialspoint.com/ruby-on-rails/rails-and-ajax.htm

Add Live Support section to mvc 3 project

Greeting to the community. This is my very first question.
I had in mind to add Livezilla live support in my MVC website, but I realised that there are some problems.
First of all, it is written in php and mysql, so is it possible to comply with MVC and sql server?
Does anybody know a similar solution (like livezilla) in my case?
PS. Excuse my poor english...
you could even look into using an iFrame to run livezilla inside of an mvc3 page if you wanted.
or, you could roll your own. if you wanted to try implementing a live response mvc3 page look into jquery and ajax asynchronous calls such as $.post and also look into the extension for controller AsyncController, and [AsyncTimeout(XXX)]. you will also have to read up on sending and receiving json objects in ajax and from a controller to the view.
Simple psuedo:
View:
setTimeOut calls a javascript function every X milliseconds
the javascript function uses json to wrap page data and pass it to the controller inside a $.post() call
Controller:
recieves page data as an model object in a post
determines if page is out of sync or not
returns relevant sync data in a json object back to the view
View:
the same javascript function receives the json object from controller
updates the page based on relevant sync data
Problem solved. I just uploaded the folder given from livezilla in the root folder of my website. Then the only need to met is to have a Mysql server to create the database for livezilla. After that php and mvc runs together with no problem.

How to upload an image using jsonp

Jsonp can be used to fetch data from supporting services but can i use it to upload images. As far as i understand javascript cannot access your file system making it impossible to upload an image using pure javascript techniques.However is there a work around. Can an image be uploaded to a server using jsonp?
I don't think you can just using json. The closest you can get is posting to a seperate iframe. Jquery has a feature where you can post a form to a hidden iframe.
http://aspzone.com/tech/jquery-file-upload-in-asp-net-mvc-without-using-flash/
If you are using jquery: http://plugins.jquery.com/plugin-tags/ajax-upload

Resources