Simple Jquery running slow, is it my code or the server?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Simple Jquery running slow, is it my code or the server?

I am using JQuery to populate a drop-down menu based on a previous drop-down menu selection.

When the user selects a 'Specialty', the script recognizes the change event and calls a PHP page passing that Specialty ID. The PHP page then generates 'Sub-Specialty' options based on that ID. The response is sent back and the 'Sub-Specialty' drop-down is populated.

The script functions; however, there is a reasonably long delay for the items to load when the 'Specialty' drop-down changes. Could this be an issue with the hosting company server or my code (note: checked the PHP/MySQL code alone and loads very fast)?

Here is the code (it was once inside document. ready but took it out thinking it would speed things up -- did not):
         // If specialty drop-down menu changes
          // Show updating image
                  // Request PHP page with specialty ID to generate show all related subspecialties
            type: "POST",
            data: "data=" + $(this).val(),
            url: "findspecialty.php",
            success: function(msg){
                if (msg != ''){
                                                 // Populate sub-specialty drop-down menu with repsonse


Any advice would help greatly.

Thanks for your time.