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>";
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.