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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:07:36+00:00 2026-06-11T05:07:36+00:00

Hello I’m coding a searching system via Ajax abit different one and I have

  • 0

Hello I’m coding a searching system via Ajax abit different one and I have a problem, is it possible to break data fetch through ajax and do foreach for each line in javascript?

Here I send the user’s search query to a php file which gives back results from database for that query..

    $.post("rpc.php", {queryString: ""+inputString+""}, function(data) { 


        $('#suggestions').html(data); // Fill the suggestions div
    });

so data coming from php file is stored inside data variable as a set but line by line,like example..

Google helps us
Facebook is a social network
Stackoverflow is the best
Im on twitter

but

$('#suggestions').html(data);

will directly put all the things inside data to suggestions html element..

I want to know is it possible to break things inside data to lines and do foreach for each line…

  • 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-06-11T05:07:38+00:00Added an answer on June 11, 2026 at 5:07 am

    Split the data by <br />, and then iterate over the resulting lines array:

    var lines = data.split("<br />");
    var $suggestions = $("#suggestions");
    for (var i = 0; i < lines.length; i++) {
      var line = lines[i];
      // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello all and thanks for the attention! I have a problem that must both
Hello I have the following code to retrieve data from my db using nhibernate
Hello I have a problem using latest vim with omnicompletion while editing a file
Hello guys i have a small problem at my console application i have a
Hello I have asp mvc view page, <%@ Page Language=C# Inherits=System.Web.Mvc.ViewPage<System.Drawing.Color[,]> %> how I
Hello The following procedure will have to move all constraints from one table to
Hello! I have this trouble: I'm searching reports by date and in html view
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
hello all i am working on a project in which i have a webpage

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.