Note that there are some explanatory texts on larger screens.

plurals
  1. PODo I need to use a selector with jQuery .load()?
    primarykey
    data
    text
    <p>I have the following:</p> <pre><code>function callback_function(a,b,c) { var aa = a; var bb = b; $('#content').html("xxx"); } $('#content').load(href, "", function (a, b, c) { callback_function(a, b, c) }); </code></pre> <p>What I want to do is to put the value "xxx" into the html of the <code>div#content</code>. Can someone explain how to do this? I think it will work with the code in the callback_function but then if that works then will the actual <code>.load()</code> also put some data into <code>#content</code>? </p> <p>Do I even need something to the left of the <code>.load()</code> if I am doing everything in the <code>callback_function()</code>. I hope this makes sense. Please note it's not production ready. I realize I need to rename parameters, do error checks and such.d</p> <p>Please note I want to use <strong>.load</strong> not .ajax. as I am using the following wrapper. Sorry in advance that it's a lot of code:</p> <pre><code>$.fn.loadWithEffect = function() { // Add effect layer this.addEffectLayer({ message: $.fn.loadWithEffect.defaults.message }); // Rewrite callback function var target = this; var callback = false; var args = $.makeArray(arguments); var index = args.length; if (args[2] &amp;&amp; typeof args[2] == 'function') { callback = args[2]; index = 2; } else if (args[1] &amp;&amp; typeof args[1] == 'function') { callback = args[1]; index = 1; } // Custom callback args[index] = function(responseText, textStatus, XMLHttpRequest) { // Get the effect layer var refElement = getNodeRefElement(this); var layer = $(refElement).next('.loading-mask'); var span = layer.children('span'); // If success if (textStatus == 'success' || textStatus == 'notmodified') { // Initial callback if (callback) { callback.apply(this, arguments); } // Remove effect layer layer.stop(true); span.stop(true); var currentMarginTop = parseInt(span.css('margin-top')); var marginTop = parseInt(span.css('margin-top', '').css('margin-top')); span.css({'marginTop':currentMarginTop+'px'}).animate({'opacity':0, 'marginTop':(marginTop-40)+'px'}, { 'complete': function() { layer.fadeAndRemove(); } }); } else { span.addClass('error').html($.fn.loadWithEffect.defaults.errorMessage+'&lt;br&gt;&lt;a href="#"&gt;'+$.fn.loadWithEffect.defaults.retry+'&lt;/a&gt; / &lt;a href="#"&gt;'+$.fn.loadWithEffect.defaults.cancel+'&lt;/a&gt;'); span.children('a:first').click(function(event) { event.preventDefault(); // Relaunch request $.fn.load.apply(target, args); // Reset span.removeClass('error').html($.fn.loadWithEffect.defaults.message).css('margin-left', ''); }); span.children('a:last').click(function(event) { event.preventDefault(); // Remove effect layer layer.stop(true); span.stop(true); var currentMarginTop = parseInt(span.css('margin-top')); var marginTop = parseInt(span.css('margin-top', '').css('margin-top')); span.css({'marginTop':currentMarginTop+'px'}).animate({'opacity':0, 'marginTop':(marginTop-40)+'px'}, { 'complete': function() { layer.fadeAndRemove(); } }); }); // Centering span.css('margin-left', -Math.round(span.outerWidth()/2)); } }; // Redirect to jQuery load $.fn.load.apply(target, args); return this; }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload