Jump to content

JQuery Help


savagenoob

Recommended Posts

Im trying to emplement JQuery Autocomplete but have minimal javascript/ajax knowledge. How do i turn:

<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",
	];
	$( "#tags" ).autocomplete({
		source: availableTags
	});
});
</script>

Into an ajax query. I need to pass the search query with id tags to a php page named searchajax.php and return the result.

Here is my shot at it, but it has errors, but at least i tried :)

<script type="text/javascript"> 
    var inputString = document.getElementById('tags');

$(function(inputString) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$('#suggestions').hide();
	} else {
		$.post("includes/searchajax.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				$('#suggestions').show();
				$('#autoSuggestionsList').html(data);
			}
		});
	}
}); // lookup

    $( "#tags" ).autocomplete({
		source: autoSuggestionsList
	});

</script>

Link to comment
https://forums.phpfreaks.com/topic/219149-jquery-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.