I want to save div content into mysql without using form and button means page should be opened in browser and it should send it's all div content to mysql table automatically.
here it is what i tried
var myVar = setInterval(function(){getElement()},5000);
function getElement()
{
var iBody = $("#frametest").contents().find(".bx-viewport").html();
document.getElementById("demo").innerHtml=iBody;
alert(iBody);
}
i want this demo div to be saved in mysql
If you don't want to use forms, I think AJAX is a great option.
var contents = $('#frametest').contents().find('.bx-viewport').html();
$.ajax({
url: 'path/to/php/script',
type: 'POST',
data: {content: contents},
success: function() {
// do something after sending data
}
});
This will send contents
to the php script defined in the url
property of the AJAX call as a POST request, and in the php script you can use the normal thing you'd do for saving it in MySQL.