Reputation: 1630
I copy an wikipedia article consiting of images and text. I paste it in to div that is set to contenteditable="true". I can see the pasted material like it looks at wikipedia.
How can I save the content of that div and include the styling and the images now it is only text that I can save? Save it e.g. as an object that could be sent to the service.
html
<div class="inputdiv"contenteditable="true"> paste here </div>
Upvotes: 0
Views: 303
Reputation: 3326
You can retrieve the contents of the div using jQuery
and post it with an ajax request to the service. E.g:
(function($){
$(function(){
var html = $(".inputdiv").html();
var jqxhr = $.post( "http://www.url-of-service.com", {input: html})
.done(function() {
alert( "success" );
})
.fail(function(jqXHR, errorMsg) {
alert( "error: " + errorMsg);
});
});
})(jQuery);
Fiddle: http://jsfiddle.net/PpaS8/1/
Make sure you put the correct url of the service instead of http://www.url-of-service.com
and the correct key for the post var instead of input:
.
Upvotes: 1