Note that there are some explanatory texts on larger screens.

plurals
  1. POgetJSON doesn't work with latest version of jQuery
    primarykey
    data
    text
    <p>This following code snippet works fine using jQuery1.2.3, but it doesn’t work with latest version of jQuery:</p> <pre><code>$.getJSON(url,{str: $$.val() }, function(j){ if (j.length &gt; 0) { var options = '&lt;option value=""&gt;' +params.firstOption+ '&lt;/option&gt;'; for (var i = 0; i &lt; j.length; i++) { options += '&lt;option value="' + j[i].optionValue + '"&gt;' + j[i].optionDisplay + '&lt;/option&gt;'; } } $dest.removeAttr('disabled') .html(options) .find('option:first') .attr('selected', 'selected'); }); </code></pre> <p>Please note that this above code is actually part of a jQuery plugin for cascading drop down list. It produces desired result if I use jQuery1.2.3. The full plugin code is as follows:</p> <pre><code>(function($){ $.fn.linkedSelect = function(url,destination,params) { var params = $.extend({ firstOption : 'Please Select', loadingText : 'Loading...' },params); var $dest = $(destination); return this.each(function(){ $(this).bind('change', function() { var $$ = $(this); $dest.attr('disabled','false') .append('&lt;option value=""&gt;' +params.loadingText+ '&lt;/option&gt;') .ajaxStart(function(){ $$.show(); }); $.getJSON(url,{str: $$.val() }, function(j){ alert('User clicked on this.'); if (j.length &gt; 0) { var options = '&lt;option value=""&gt;' +params.firstOption+ '&lt;/option&gt;'; for (var i = 0; i &lt; j.length; i++) { options += '&lt;option value="' + j[i].optionValue + '"&gt;' + j[i].optionDisplay + '&lt;/option&gt;'; } } $dest.removeAttr('disabled') .html(options) .find('option:first') .attr('selected', 'selected'); }); // end getJSON }); // end change }); // end return each }; // end function })(jQuery); </code></pre> <p>Please note that it can't generate the following alert message </p> <pre><code>alert('User clicked on this.'); </code></pre> <p>what is written inside the getJSON function for debugging purpose if I use latest version of jQuery. And I have also traced using JS debugger, it can't step into the getJSON function if I use latest version of jQuery. But, it shows this alert message if I use jQuery1.2.3. </p> <p>In error console, warning messages are: </p> <pre><code>Warning: reference to undefined property b.p.height Source File: http://localhost//js/jquery.jqGrid.min.js Line: 99 Warning: reference to undefined property b.p.serializeGridData Source File: http://localhost/js/jquery.jqGrid.min.js Line: 62 Warning: reference to undefined property jQuery.event.triggered Source File: http://localhost/js/jquery1.7.js Line: 2924 Warning: reference to undefined property elem[jQuery.expando] Source File: http://localhost/js/jquery1.7.js Line: 1719 </code></pre> <p>What should I change to adapt with latest version of jQuery. Thank you. </p>
    singulars
    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