Solved

Displaying JSON responses on a page.

Posted on 2014-01-12
5
246 Views
Last Modified: 2014-05-12
Hi experts,

Thank you as always for taking a look at my question which i am hoping is an easy one.

I have the below web page.

<!DOCTYPE html>
   <head>
<script type="text/javascript" src="scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="totalcall.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.3/ui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="scripts/jquery-ui-1.10.3/themes/base/jquery-ui.css" />
 
        <script type="text/javascript">
                $(document).ready(function(){
                    $("#term").autocomplete({
                        source:'getautocomplete.php',
                        minLength:3
                    });
                });
        </script>
   </head>
 
   <body>
 
      <form method="post" action="">
             Name : <input type="text" id="term" name="term" />
      </form>
  
   </body>
</html>

Open in new window


Essentially this sends data off to a php page, which submits the data and returns the results. I know the curl is working because i can see the response when I turn on the dev option in firefox.

What I need to know is how can I get the results to display in either an iframe or a small table on the html webpage.  If you need any of the JS files please advise.

many thanks again!!
0
Comment
Question by:mavmanau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39775508
You can use appendTo
http://api.jqueryui.com/autocomplete/#option-appendTo
        <script type="text/javascript">
                $(document).ready(function(){
                    $("#term").autocomplete({
                        source:'getautocomplete.php',
                        minLength:3,
                        appendTo: "#id-of-div"
                    });
                });
        </script>

Open in new window

The proviso of this is the div you want to show the results in must be in the same container as your input field.
0
 

Author Comment

by:mavmanau
ID: 39775546
Hi,

I tried this, but nothing is still coming through.

<!DOCTYPE html>
   <head>
<script type="text/javascript" src="scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="totalcheck.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.3/ui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="scripts/jquery-ui-1.10.3/themes/base/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="totalcheck.css" />
 
        <script type="text/javascript">
                $(document).ready(function(){
                    $("#term").autocomplete({
                        source:'getautocomplete.php',
                        minLength:3,
						appendTo: "#resultsname"
                    });
                });
        </script>
   </head>
 
   <body>
 
      <form method="post" action="">
             <p>Name :
  <input type="text" id="term" name="term" />
             </p>
             <div name="resultsname" id="resultsname"></div>
             <p>&nbsp;</p>
      </form>
  
   </body>
</html>

Open in new window

0
 

Author Comment

by:mavmanau
ID: 39775560
I have it now displaying "No results found then the text box - which is strange because i can see the data that is being generated from the PHP file.  

Do I need to show you my PHP file perhaps?  or Am i calling it incorrectly?
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39775663
Try
<!DOCTYPE html>
   <head>
<script type="text/javascript" src="scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="totalcheck.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.10.3/ui/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="scripts/jquery-ui-1.10.3/themes/base/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="totalcheck.css" />
 
        <script type="text/javascript">
                $(document).ready(function(){
                    $("#term").autocomplete({
                        source:'getautocomplete.php',
                        minLength:3,
						appendTo: "#resultsname"
                    });
                });
        </script>
   </head>
 
   <body>
 
      <form method="post" action="">
             <p>Name :
  <input type="text" id="term" name="term" />

             <div name="resultsname" id="resultsname"></div>
             </p>
      </form>
  
   </body>
</html>

Open in new window

0
 

Author Closing Comment

by:mavmanau
ID: 40060841
perfect.  Thank you, that solution worked brilliantly.

apologies for time taken to answer.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question