I've seen many js var to php question asked but none seem to help me as its either to complicated or doesn't fit my requirements. I'm looking to transfer three variable in js called title, body and author. Body being a very long string therefor I cannot place in URL. I am looking for the simplest Ajax code possible that follows this: js var already defined -> ajax -> php var Here is the code I've got so far:
<script>
var title;
var body;
var author;
function post(){
title = document.getElementById("title").value;
body = document.getElementById("body").value;
author = document.getElementById("author").value;
}
//Insert ajax code here
<?php
$title;
$body;
$author;
$post = "INSERT INTO post (title, body, author) VALUES ($title,$body,$author)";
$sql = mysqli_query($conn,$post);
?>
</script>
Thank you in advance!