javascript - Displaying result of AJAX request -
i have looked far , wide how below, have come short, , struggling find resource explains ajax , how works.
i have sent through ajax request php
file below code, , using network tab in mozillas developer console
, see response code (which echo'd out info inside html elements)
although can see response, don't know how display it, using below code (which i've compiled after looking through numerous similar questions on stack overflow). please have , see why not displaying?
<div id='picoutput'></div> <script> $.ajax({ url: 'resources/listposts.php', type: 'post', datatype: \"json\", data: { uname: $('$uname').val(), }, success:function(data) { if(data) { // $('#picoutput').html(data).value; } else { // } } } }); </script>
the response is
<div id='post'><div id='postleft' style='float:left;clear:left;width: 15%;'> <div id='profilepic2'> <img src='../uploads/default1562925803.jpg' id='profilepic'> </div> <h4 style='margin-left:10px;margin-top:10px;;color:grey'>dowayne breedt<br>support<br>2016-05-24</h><br> </div> <div id='postright'style='width: 82%;float:right; padding: 10px;background-color:white;height:inherit'> <h2>...</h2> <p>only refresh if extend off<br /> </p> </div> </div>"
put , see 'data' object including. check using firebug etc use it.
success:function(data) { console.log(data); $('#picoutput').val(data.id); }
Comments
Post a Comment