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

  • Home
  • SEARCH
  • 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 8441105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:28:44+00:00 2026-06-10T08:28:44+00:00

MY AIM Use jQuery UI Autocomplete to search for a book and when a

  • 0

MY AIM

Use jQuery UI Autocomplete to search for a book and when a book is clicked from the suggestion dropdown, populate the remainder of the HTML form with details of the book selected by using the select function of the autocomplete.

THE PROBLEM

As long as the returned data does not contain a line break (I have a table field called description in the database and it has line breaks in the stored data ) the autocomplete works like a charm. But if I include the description field data into the returned array, the suggestion dropdown fails to show up. However when checked with Firebug, data is being returned; just not showing up

THE CODE

// STORING INFORMATION FROM THE DATABASE
$items[$r['book_id']] = array('name'=>$r['book_name'],
                              'category'=>$r['c_id'],
                              'author'=>$r['book_author'],
                              'vendor'=>$r['book_publisher'],
                              'edition'=>$r['book_edition'],
            Culprit here -->  'description'=>$r['book_description'],
                              'price'=>$r['book_price'],
                              'date'=>$r['date']);



 // DATA FOR POPULATING THE HTML FORM (USING ui.item.<index name>)
   $result = array();
   foreach ($items as $key=>$value)
   {
      array_push($result, array("id"=>$key,
                                "label"=>$key."-".$value['name'],
                                "value" => strip_tags($value['name']),
                                "name" => $value['name'],
                                "cat" => $value['category'],
                                "author" => $value['author'],
                                "vendor" => $value['vendor'],
                                "edition" => $value['edition'],
                                "description" => $value['description'],
                                "price" => $value['price'],
                                "date" => $value['date']));
    }
    // $result is then supplied to a function which converts the data to json

If I remove the description entry from the $items and $result arrays, everything works as expected. I tried a couple of things after going through SO threads here:

WHAT I TRIED

Tried str_replace('\n', '\\n', $r['book_description'])

Tried str_replace('<br />', '\\n', $r['book_description'])

Out of frustration even tried urlencode($r['book_description'])

But none of them seemed to work. Is there a workaround for this one?

Thanks in advance.


UPDATE

Using json_encode on the returned set is resulting into:

enter image description here

  • 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-10T08:28:45+00:00Added an answer on June 10, 2026 at 8:28 am

    Are you using json_encode()? ..It should escape everything for you. You could also try something like

    $newDesc = str_replace(PHP_EOL, "", $r['book_description']);
    

    or

    $newDesc = str_replace(chr(10), "", $r['book_description']);
    $newDesc = str_replace(chr(13), "", $newDesc);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

basically my aim is to use JQuery to post back an x & y
My project is to implement minimum spanning tree using java. I aim to use
which column i need to use to join V$session and V$sqlarea? My main aim
Building a site on CargoCollective, but it appears they use jQuery 1.4.2 which seems
I am a very, very mediocre programmer, but I still aim to use the
My aim is to use a member function in a for_each call. So I
My aim is to retrieve some data from a global array which is defined
My aim is to retrieve some data from a global array which is defined
Hey, friend. as show in title: My aim is use ajax to connect with
I am trying to use multimaps in C++. The main aim is that there

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.