Vamshi P Vamshi P - 3 months ago 11x
Javascript Question

jquery load() only once for one file


here selval is value of a dropdown option. dropdown options and the jsp's which i am loading
have the same names. that way i am using jquery's load() to load the jsp file into a div.

here problem is there are multiple div's which generate dynamically with name documentProperties and
a number attatched to it for id uniqueness. i need to load the jsp only once, if one jsp is already loaded
into a div don't load that, show any alert error saying this document is already loaded.


What about adding a class:

$("#documentProperties"+id + ":not(.loaded)").load("doctypes/"+selval+".jsp", function(){


var jspLoaded = [];


if (jspLoaded.indexOf(selval) === -1) {
  $("#documentProperties" + id).load("doctypes/" + selval + ".jsp", function() {