in following case I want my script to running post.php. That works fine. But while running the post.php file, in it a variable should be created with content "1". And I want to get the variable in my javascript back. So there are two files:
part of index.php
<script type="text/javascript">
function post()
{
var message = $('#message').val();
$.post('post.php', {postmessage:message},
function(data)
{
$('#result').html(data);
});
}
</script>
and then I have the post.php where the variable with content "1" should be created.. Then I want to get back it in index.php in the script. How can I do this?
Why do I want to do this? When in post.php a variable with content "1" will be created, >>I think it has to be a $_POST variable?<< then I want to clear my form field because the action in post.php went successfully.
$.post()is a shorthand form of$.ajax(), so learn the longer form first.