Jump to content

Recommended Posts

I've set up a php page to process my customers by customer name and the business code which references the account (busname, buscode).  It's pulled from MySQL using ORDER BY busname ASC.

 

When I run the php on it's own, the xml is echoed properly and they all appear in alphabetical order. 

 

I'm using this jquery function to process the xml:

function getCustomerList() {
//this code modeled after tutorial at: http://think2loud.com/reading-xml-with-jquery/
  $.ajax({
    type: "POST",
    url: "php/selectcustomer.php",
    dataType: "xml",
    success: function(xml) {
		$(xml).find('Customer').each(function(){
			var buscode = $(this).find('buscode').text();//this refers to the current Customer
			var busname = $(this).find('busname').text();
			var selectlist = '</BR>'+buscode+'</br>'+busname+'</hr>';
			$('#rightColumn').prepend(selectlist);
		});
	}   	
  });
}

 

The function is called inside document.ready so it runs when the page loads.

 

This code adds the list to the top of #rightColumn as expected, but the list is ordered in reverse alpha-order.  The easy fix is just to reverse sort on the php side, but I'd like to understand why it's doing it so I understand jQuery better since I'm just learning it. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.