Solved

Spry AutoSuggestion With Ajax

Posted on 2008-06-12
1
941 Views
Last Modified: 2012-08-13
Hi,
I try to use Spry.AutoSuggest widget in my project with ajax. But it doesn't work with ajax. In normally there is no problem.
I've attach code.
Spry link : http://labs.adobe.com/technologies/spry/

<?php
if (isset($_GET["progress"])){
	?>
	<div id="spryautosuggest1">
	  <input type="text" name="text1" id="text1" />
			<div id="productMenu" spry:region="dsProducts1">
				<div spry:repeat="dsProducts1" spry:suggest="{DISPLAY_TEXT}">
					<div>{DISPLAY_TEXT}</div>
				</div>
			</div>
	</div>	
	<?php
	exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>CRM</title>
<script src="/js/Spry_1_6_1_022408/widgets/autosuggest/SpryAutoSuggest.js" type="text/javascript"></script>
<script src="/js/Spry_1_6_1_022408/includes/xpath.js" type="text/javascript"></script>
<script src="/js/Spry_1_6_1_022408/includes/SpryData.js" type="text/javascript"></script>
<link href="/js/Spry_1_6_1_022408/widgets/autosuggest/SpryAutoSuggest.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/prototype.js"></script>
 
<script language="javascript">
var sprysuggest1;
var dsProducts1;
 
function getSuggestionDiv(){
	new Ajax.Request("a.php?progress=yes",{onComplete:getSuggestionDivComplete});
}
 
function getSuggestionDivComplete(request){
	dsProducts1 = new Spry.Data.XMLDataSet("adobe_products-xml.txt", "/FIELDS/FIELD", { sortOnLoad: "DISPLAY_TEXT" });
	$("myDiv").innerHTML=request.responseText;
	sprysuggest1 = new Spry.Widget.AutoSuggest("spryautosuggest1", "productMenu", "dsProducts1", "DISPLAY_TEXT");
        //it should be work after here. but doesn't work.
	
}
 
</script>
 
<script type="text/javascript">
	
</script>
</head>
<body>
<div id="myDiv">
</div>
<button onclick="getSuggestionDiv();">Get div for auto suggestion</button>
 
</body>
</html>

Open in new window

adobe-products-xml.txt
0
Comment
Question by:erenpasa
1 Comment
 

Accepted Solution

by:
erenpasa earned 0 total points
ID: 21778677
I've find my solution my own.
<?php
if (isset($_GET["progress"])){
        ?>
        <div id="spryautosuggest1">
          <input type="text" name="text1" id="text1" />
                        <div id="productMenu" spry:region="dsProducts1">
                                <div spry:repeat="dsProducts1" spry:suggest="{DISPLAY_TEXT}">
                                        <div>{DISPLAY_TEXT}</div>
                                </div>
                        </div>
        </div>  
        <?php
        exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>CRM</title>
<script src="/js/Spry_1_6_1_022408/widgets/autosuggest/SpryAutoSuggest.js" type="text/javascript"></script>
<script src="/js/Spry_1_6_1_022408/includes/xpath.js" type="text/javascript"></script>
<script src="/js/Spry_1_6_1_022408/includes/SpryData.js" type="text/javascript"></script>
<link href="/js/Spry_1_6_1_022408/widgets/autosuggest/SpryAutoSuggest.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/prototype.js"></script>
 
<script language="javascript">
var sprysuggest1;
var dsProducts1;
 
function getSuggestionDiv(){
        new Ajax.Request("a.php?progress=yes",{onComplete:getSuggestionDivComplete});
}
 
function getSuggestionDivComplete(request){
        dsProducts1 = new Spry.Data.XMLDataSet("adobe_products-xml.txt", "/FIELDS/FIELD", { sortOnLoad: "DISPLAY_TEXT" });
        $("myDiv").innerHTML=request.responseText;
        sprysuggest1 = new Spry.Widget.AutoSuggest("spryautosuggest1", "productMenu", "dsProducts1", "DISPLAY_TEXT");
        //it should be work after here. but doesn't work.
 
        Spry.Data.initRegions();//I've added this line for init html again.It works now.
}
 
</script>
 
<script type="text/javascript">
        
</script>
</head>
<body>
<div id="myDiv">
</div>
<button onclick="getSuggestionDiv();">Get div for auto suggestion</button>
 
</body>
</html>

Open in new window

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
php56-php-mcrypt for rhel7 php56 1 54
angular 2 problem setting an object inside a subscribe section 15 20
Autocomplete with Jquery Question 2 20
Selected in an option list 13 21
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

829 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