I'm need a little help as I'm new to this what I'd like to do is make the div box give the output of the PHP and after some research I believe using json is the best thing to do. So here is my jQuery, I post the data to the PHP and show the div box. This all works. <script type="text/javascript"> function remove() { var userid = <?= $u['id']; ?>; var usertype = "PA"; $.ajax({ type: "POST", url: "connectionssu.php", dataType: 'json', data: "userid=" + userid + "&usertype=" + usertype, success: function(){ $(".user"+userid).remove(); $('div.success').fadeIn(); } }); } </script> Code (markup): Then my PHP picks it up using if(isset($_POST['userid'])){ $id = $_POST['userid']; $type = $_POST['usertype']; mysqli_query($dbc, "UPDATE connections SET requestorid = '1' WHERE requestingid = '$id' AND requestingtype = '$type'"); echo "done"; } PHP: At the moment a div box fades in as displayed below, however I would like the div box content to give the output from the PHP. <div class="success" style="display:none;"><span style="color:green;font-weight:bold;">You Ended The Connection</span</div> Code (markup): Can someone help me?
In the php file, you can return the output you want to see in the div. in the .ajax() - function you already use the success-parameter with a function. However if you define function(returnValue), the output you returned in the php file will be stored in the "returnValue" - variable, so you can add this into your div... hth
no, if you just want to get an html - output, you can use "html" as datatype too $.ajax({ type: "POST", url: "submit.php", data: submitData, dataType: "html", success: function(msg){ } }); Code (markup): this is how I used it for a commenting-system. The submit.php returns the new comment as html-code and in the success-function I simply add it to the right place in the DOM