php - JQuery Load functions producing unexpected results -


to follow on previous question here function used determine elements selected radio buttons , checkboxes loaded on right hand sign , elements loaded out via 'blank2.html'. problem is loading wrong elements in @ wrong points in time. here code.

function product_analysis_global() {  $(':checked').each(function() {     var alt = $(this).attr('alt');     var title = $(this).attr('title');     if ($('#product_quantity_pri_' + alt).attr('title') != title) {         $('#product_' + alt).load(title);          $('#product_quantity_pri_' + alt).attr('title', title);          $('#product_quantity_pri_' + alt).val($(this).val());      } else if ($('#product_quantity_pri_' + alt).attr('title') != 'http://www.divethegap.com/update/blank2.html') {          $('#product_' + alt).load('http://www.divethegap.com/update/blank2.html');          $('#product_quantity_pri_' + alt).attr('title', 'http://www.divethegap.com/update/blank2.html');      } else return false ;  });  

}

take @ implementation here , see precisely mean. http://www.divethegap.com/update/diving-trips/adventure-training , click on beginners load in form.

i believe problem lies in $(this).attr('alt') , $(this).attr('title') collecting 1 attribute box checked not of them.

an additional feature code have treat disabled checkbox or radio button @ unchecked box , load out via 'blank2.html'

$.load fires off asynchronous request, therefore subsequent statements evaluated before request finishes (at least in vast majority of cases).

you need want within success callback, ensure guaranteed happen once $.load has completed:

// make sure make current context available within callback var = this; $('#product_' + alt).load(title, function() {         $('#product_quantity_pri_' + alt).attr('title', title);          $('#product_quantity_pri_' + alt).val($(that).val());  });  

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -