javascript - Ajax returns proper repsonse but not displaying html -


I have a page where I am getting data from SQL database through a call through jQuery and Ajax . When the page loads, the script is getting data from the PHP file. Ajax is getting the right response (I can see it in firebug), but it is not displaying it in the form of HTML in the div.

Franchise:

  & lt; Script src = "//code.jquery.com/jquery-1.11.0.min.js"></script> & Lt ;? Php foreach ($ news item as item):? & Gt; & Lt; Li style = "border-top: 5px solid # a1cb2f;" Class = "block" id = "post_ <" php eq $ $ item ['date_added']? & Gt; & lt; img class = "post_user_img" src = "& lt ;? Php echo "/userdata/profile_pics/".$item['user_img ']? & Gt; ">  
script type =" text / javascript "& gt; ; Function get_userdata () {user_id = "& lt ;? Php echo $ item ['added']]? & Gt; Var datastring = 'user_id =' + user_id; $ .ajax ({type: "post", url: "/get_userdata.php", data: datastring, datatype: "html", success: function } {$ ('.added') .html (data);}}}; get_userdata (); & lt; / script & gt; & lt; / br & gt; & lt; / br & gt; << Code:

> PHP:

  & lt ;? php included ("include / session.php"); contains ("include / connect_to_mysql.php"); if (isset ($ _ $ 'User_id']) $ $ user_id = $ _POST ['user_id']; $ Sql ​​= mysql_query ("select member where id = '$ user_id'"); $ News = array (); $ Line = mysql_fetch_assoc ($ Sql);} resonance "& lt; a href = 'user_profile.php? U =". $ Line [' id ']. "& Gt;" $ line [' first name '] ". $ Line ['Last Name'] "& lt; / a & gt;";? & Gt;  

Now, I have tried to search for a lot of places and I have seen many stacks Have seen questions, but I was not able to get the answer. If there are any other questions that are exactly the same, please take me in that direction. This will be great for you.

It looks like you are not returning valid HTML, try:

  echo "& lt; a href = 'user_profile.php? U =". $ Line ['id']. ' '& Gt; ". $ Line ['firstname']." ". $ Line ['alias']." & Lt; / A & gt; ";  href  to close the attribute, see additional  '. 


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -