Reputation: 1601
I have this code to create a div inside a div with id container when you press a button
jquery
$(document).ready(function(){
$("#add").click(function(){
$('#container').append( $('<div>test</div>').addClass('div-color') );
});
});
html
<div id="container">
</div>
How can I save the container div and the dynamically generated data in a file on the server? For example, if the user clicks the button twice, I want to save the following in a test.html file on the server (container div and everything that's in it).
<div id="container">
<div class="div-color">test</div>
<div class="div-color">test</div>
</div>
Guess it is not possible with javascript and if so, PHP is OK to use.
Upvotes: 0
Views: 688
Reputation: 4121
Try something like this
$.ajax({
type: "POST",
url: 'save.php',
data: { content: $('#container').html() }
});
Then receive POST data and save it to file with php.
Upvotes: 1