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 4613814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:36:28+00:00 2026-05-22T01:36:28+00:00

Basically, the code below will generate divs which are then captured using the jquery

  • 0

Basically, the code below will generate divs which are then captured using the jquery .ajax function as the data object and appended to the div with ID=’textResp’:

while($row = mysql_fetch_array($result_new))
{

/* Echo the result as Jquery */
    echo "
    <script> 
    jQuery(document).ready(function(){  
        $('#textResp').append(<div>".$row['Title']."</div>');
    }); 
    </script>";
}

This code works fine, but when I add a class to the div:

$('#textResp').append(<div class='class'>".$row['Title']."</div>');

The whole world blows up and it sends the ajax calls into an infinite loop.

Has anyone ever heard of this… or am I just writing my javascript wrong?

I know that I shouldn’t be echoing javascript, but I really didn’t want to have to explode the result of the string captured in the ‘data’ object to add the '<div class='class'>explode_result_1</div>'

  • 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-22T01:36:28+00:00Added an answer on May 22, 2026 at 1:36 am

    I don’t see how this would cause an infinite loop, but you have quote issues. First, you’re missing one before the <div. But more importantly, you’ll need to escape some of those quotes. You have double quotes used for your php strings and then single quotes within that used for your javascript. The problem comes in when you put a class and try and use single quotes for that too, it ends the javascript string and just makes a mess. Try this:

     "$('#textResp').append('<div class=\'class\'>".$row['Title']."</div>');"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following jquery code. basically i will have several overlapped divs and
If I enter the code below, I get an error. Basically, the foreach will
Hi I have this code below which basically after 25 seconds of showing the
Basically this code below returns the right information, but I need to add the
I have a bit of code that basically reads an XML document using the
I've got some VB code (actually VBA) which is basically the same except for
I recently came across this in some code - basically someone trying to create
I have a block of code that basically intializes several classes, but they are
Basically I have some code to check a specific directory to see if an
I basically need to know how to import SQL code into Access. I've tried

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.