0

I have a list of categories with different titles from A-Z. I want to sort the categories alphabeticaaly on clicking a particular alphabet... I have used jquery and ajax..

Alphabetics placed are as follows

<?php
                        $a=range("A","Z");
                            foreach($a as $char){
                            echo "<a href='javascript:void(0)' class='faq_letter'  rel='".$char."'>".$char."</a>";
                            }
                        ?> 

The script is as follows

<script type="text/javascript">
                    $(document).ready(function(){
                        $(".faq_letter").click(function(){
                            $("#padding_content").hide();
                            var letter = this.rel;
                            //alert(letter);
                            var xmlhttp;
                            if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
                                xmlhttp=new XMLHttpRequest();
                            }
                            else{// code for IE6, IE5
                                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                            }
                            xmlhttp.onreadystatechange=function(){
                                if (xmlhttp.readyState==4 && xmlhttp.status==200){
                                    document.getElementById("categoriesList").innerHTML=xmlhttp.responseText;
                                }
                            }
                            xmlhttp.open("GET","faq_categories.php?title="+letter,true);
                            xmlhttp.send();
                        });
                    })
                </script>

However an errors occurs near the line xmlhttp.send(); called as uncaught exception: Syntax error, unrecognized expression: . What could be the problem?

faq_categories.php page

<?php
    $letter = $_GET['title'];
    $sql1 = "SELECT * FROM faq_categories WHERE title LIKE '".$letter."%' ORDER BY title";
    $query1 = mysql_query($sql1);
    echo "<div id='categoriesList'>";
    if(mysql_num_rows($query1)>0){

    while($result1=mysql_fetch_array($query1)){
    echo $result1['title']."<br/>";
    }

    }
    else if(mysql_num_rows($query1)==0){
    echo "No results found";
    }
    echo "</div>";
?>
2
Contributors
1
Reply
14
Views
4 Years
Discussion Span
Last Post by imBaCodes
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.