Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Jquery autocomplete return data from script

Posted on 2013-11-19
3
Medium Priority
?
382 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 2000 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 34

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
 
LVL 1

Author Closing Comment

by:nachtmsk
ID: 39660127
Thanks that worked!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

971 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