I have all my shipping calculations working, but there is an ajax call that displays the total result in the checkout page. (I'm completely unfamiliar with ajax - so any advice would be wonderful.)

The total is calculated first and numbers are saved in a hidden input field. This part is all working. Then the total is sent to this call:

ajax.post("index.php",usps_method_switch,"ajax=true&uspsswitch=true&key1="+key1+"&key="+key+"&total= "+total);

var usps_method_switch=function (results){
shipping = results.split('---');
shipping1 = shipping[1];
jQuery('.total > .pricedisplay').remove();
jQuery('.total > .totalhead').after(shipping[0]);
jQuery('.postage > .pricedisplay').remove();
jQuery('.postage > .postagehead').after(shipping1);
jQuery('.total < .pricedisplay').remove();
jQuery('.total < .totalhead').after(shipping[0]);
jQuery('.postage < .pricedisplay').remove();
jQuery('.postage < .postagehead').after(shipping1);

The keys are actually useless now, only the total is important. But if I try to remove them, the call seems to completely fail.

I found the ajax.post section of code, but do not understand it:


ajax.send=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseText)};if (m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)};

I used alert on the results sent by that code to see what it actually outputs and it's the line of html in the checkout page that uses span tags for formatting and displays the total. But I don't understand how it is updating that total in the html to make it display the correct amount. I'm assuming that some part of one of those calls is calling another separate function where that html is put together. If someone could at least point out what I should be looking for, I might be able to get a step further.

Thanks for any help.