json jquery post request
Posted
by
John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2012-06-11T10:14:54Z
Indexed on
2012/06/11
10:40 UTC
Read the original article
Hit count: 224
<script type="text/javascript">
$(document).ready(function() {
$("a").click(function() {
var content = $('#content').html();
var data = {"content":content};
$.ajax({
type: "POST",
dataType: "json",
url: "ajax.php",
data: {content:content},
success function (data) {
alert('Hello!');
}
});
});
});
</script>
<div id="content"><?php echo $content; ?></div>
ajax.php
echo json_encode($_POST['content']); ?>
Nothing happens... WhatI really want to achieve is to get that alert box and get the return data, but I am lost since I don't get any errors or nothing.
© Stack Overflow or respective owner