Solved

Jquery autocomplete return data from script

Posted on 2013-11-19
3
366 Views
Last Modified: 2013-11-19
Hi,
I'm trying to use the auto-complete function in Jquery to by returning data from a perl script.
I started with an example from the jquery site (see below). The example works fine when I use the local availabletags array, but when I try to call the script 'getnames.pl', nothing happens. I put a log file into the script and I can see the script is never called.

If I run the script manually it works fine.

I think the issue is that the script isn't be called/executed properly.
I am running Windows 2008. I have execute permissions set correctly on the directory that script resides in. I know this because I've tested other scripts in that directory using ajax calls.

I'm thinking the issue is someplace around here:
$( "#tags" ).autocomplete({
source: "C:\inetpub\wwwroot\f\getnames.pl"
});

Open in new window


Please help.
Thanks!
Nacht


---------------------------
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: "C:\inetpub\wwwroot\f\getnames.pl"
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" />
</div>
</body>
</html>

Open in new window

-----------------------
0
Comment
Question by:nachtmsk
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39659955
use an http or https source, not a pth to your file
your page MUST be on the same http(s) server
0
 
LVL 32

Expert Comment

by:Big Monty
ID: 39659977
you may also want to specify the data type as JSON in your ajax call:

$( "#tags" ).autocomplete({
source: url,
dataType: "json"
});
0
 

Author Closing Comment

by:nachtmsk
ID: 39660127
Thanks that worked!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now