I trying to send HTML code to php file so i can save into database.
I am getting HTML code from tinyMCE.
I tried all method JSON, encodeURIComponent, encodeURI and escape().
It works perfectly on localhost (on my PC using Wampserver) but not on server (hosted on namecheap).
When i am send simple value like "Hello world" it works perfectly but not full HTML code.
Please check the below code i am using -
$('#updatehtml').on('click', function(e){
e.preventDefault();
tinyMCE.triggerSave();
var templatedata = $('#htmldata').val();
$.ajax({
type:"POST",
url: "url to php file",
data: {template : templatedata},
dataType: "html",
success: function (data){
alert(data);
console.log(data);
}
});
});
HTML
<html>
<head>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Sevillana" />
<style>
body{background: #ffffff; font-family: Lucida Sans; width: 80%; margin: 0 auto; border: 1px solid gray; border-radius: 10px; color: #353333;font-size: 14px;}
p{background: #b3fc7b; border-bottom: 3px #b3fc7b solid; background-repeat: no-repeat; padding: 3em; color: #FFF; clear: left; text-align: center; border-radius: 10px 10px 0px 0px;}
h1{text-shadow: 1px 7px 5px #000;font-family: Sevillana;font-size: 4em;margin:0px;}
h2{width: 89%;margin: 0 auto;padding: 0px 0px 5px 0px;font-family: Sevillana;font-size: 2em;color: #FFF; border-radius:10px 0px 10px 0px; background: #b3fc7b;text-shadow: 1px 2px 5px #000;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
in PHP
<?php
print_r($_POST);
?>
ERROR:
POST https://www.mywebiste.com/phpfile 404
ISSUE RESOLVE after killing myself 3 days -
https://stackoverflow.com/questions/44623323/handling-json-data-in-codeigniter-controller