Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7420841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:18:33+00:00 2026-05-29T08:18:33+00:00

I have a simple ajax call inside a javascript function to a php file,

  • 0

I have a simple ajax call inside a javascript function to a php file, which searches the DB and returns formatted html. Alls fine, but for some reason the returned html is being wrongly formatted.

Javascript:

$.ajax(
{ 
  url: "getItems.php?lastID=10",
  success: function(html)
  {
   if(html)
   {
    $("#main").prepend(html);      
   }
  }
 });

getItems.php

<?php
mysql_connect();
$lastID = $_GET['lastID'];  
$result = mysql_query("SELECT ...");

while ($row = mysql_fetch_assoc($result)) 
{
    echo '<span class="iteminfo"> ';    
    echo '<a class="username" href="http://x.com/'.$row['UserName'].'" target="_blank"/>'.$row['UserName'].'</a><br/>';
    echo '<a class="status" href="http://x.com/'.$row['UserName'].'/c/'" target="_blank" />'.$created_at.'</a></span>';
} 
?>

which should return (and it returns this correctly in Firebug)

<span class="iteminfo"> 
<a class="username" href="http://x.com/username" target="_blank"/>username</a><br/>
<a class="status" href="http://x.com/username/c/" target="_blank" />the date</a>
</span>

but instead its outputting:

<span class="iteminfo"> 
<a class="username" href="http://x.com/username" target="_blank"/></a>username<br/>
<a class="status" href="http://x.com/username/c/" target="_blank" /></a>the date
</span>

and I’ve no idea why.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:18:34+00:00Added an answer on May 29, 2026 at 8:18 am
    while ($row = mysql_fetch_assoc($result)) 
    {
        echo '<span class="iteminfo"> ';    
        echo '<a class="username" href="http://x.com/'.$row['UserName'].'" target="_blank">'.$row['UserName'].'</a><br/>';
        echo '<a class="status" href="http://x.com/'.$row['UserName'].'/c/'" target="_blank" >'.$created_at.'</a></span>';
    } 
    

    You have closed a tag wrong manner

    <a> content </a>
    

    but u have used

    <a/></a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple jquery/ajax request to the server which returns the structure and
I have written a simple jQuery.ajax function which loads a user control from the
I have a function which makes an AJAX request to a server and returns
I have a simple jquery ajax call which posts a car manufacturer and responds
I have this ajax call: $('.ajaxtrigger2').click(function(){ $('#target').load('xxx.html'); ... how to append a Loading msg
I have a simple ajax call: $.ajax({url: my_url_here, dataType: 'text', success: function(data, textStatus) {
I have a simple $.ajax call that returns a response that looks like this:
I had a realtivley simple ajax application, which I have broken up to be
I have a simple HTML. I am using the JQuery for AJAX purpose. Now,
I have an ajax form in asp.net mvc which is as simple as this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.