Partial Load Multiple Div with 1 .get/.ajax call
Hi,
I am trying to update 2 div with a .ajax (i tried also .get ) call and i make this code working, so that the updating is realized within 2 url calls.
but i can 't figure out how to do it within 1 call?
if i try the read the data var then i get the innerHTML of the clicked node (dhis)
i thought i could read up the data var and extract somehow the innerHTML of #checkout_basketList
but i can't because .ajax/.get somehow takes the innerHTML of the clicked node (dhis).
so i have to make a new call that i do with .load (because of the partial load capabillities)
but then again its stupid to do 2 call when all the info is already in the first call, is mine approch not good.
sorry not so good with jquery (and english) more of a php dude. but still jQuery rocks :)
- jQuery(document).ready( function($) {
- $('.link').live('click', function() {
- dhis = $(this);
-
- RETURN_POSTID = do_some_js( dhis, 1 );
- return false;
- });
- });
-
- function do_some_js( dhis, doAjax ) {
- loadingImg = dhis.prev();
- loadingImg.show();
- beforeImg = dhis.prev().prev();
- beforeImg.hide();
- url = document.location.href.split('#')[0];
-
- rawparams = dhis.attr('href');
- params = rawparams.replace('?', '') + '&ajax=1';
-
- nostripparams = rawparams + '&ajax=1';
- fixedparams = params.replace(document.location.href, '');
-
- postid = getParameterByName( 'postid', nostripparams );
- if ( doAjax ) {
-
- jQuery.ajax({
- url: url,
- data: fixedparams,
- context: document.body,
- success: function(data){
-
- dhis.parent().html(data);
-
- if(typeof wpfp_after_ajax == 'function') {
-
- do_some_after_ajax( dhis, url ); // i send only the url because there is no need to do same query again.
- }
-
- loadingImg.hide();
-
- alert('Load was performed.');
- }
- });
- }
- return postid;
- }
- function do_some_after_ajax(dhis, wpurl) {
- if (dhis.hasClass('add-sidebar')) {
- jQuery( "#checkout_basketList" ).load(wpurl+" #dyn_checkout_basketList");
- }
- }
- function getParameterByName( name, params )
- {
- name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
- var regexS = "[\\?&]"+name+"=([^&#]*)";
- var regex = new RegExp( regexS );
- var results = regex.exec( params );
- if( results == null )
- return "";
- else
- return decodeURIComponent(results[1].replace(/\+/g, " "));
- }