How to post value without refresh page with jquery $post? Click test1 ,show test1 in div2, click test2,clear div2 and show test2. Thanks. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $.post('index.php',{"id":"div1","name":"post"}); </script> <div id="div1"> <ul> <li> <a href="index.php" name="post">test1</a> </li> <li> <a href="index.php" name="post">test2</a> </li> </ul> </div> <div id="div2"> this is a <? $_POST["name"]; ?>, just a test. </div> HTML:
You could make an .ajax() or .post() call to an .php - file, which returns the result (as a div for example). In the .ajax()-function there is an attribute success. With this attribute you can define a function that is called after the ajax-call has finished: $.ajax({ type: "POST", url: "submit.php", data: submitData, dataType: "html", success: function(msg){ } }); Code (markup): now you can access the data that you returned in the "submit.php" file over the "msg"-variable in jquery and add it to the div you want to. But I don't know if there is a way to access the $_POST - values like you tried to do...