I am building a page with ajax a jquery. I have built the page with a scrolling nav and it works fine. I am taking the next step and loading the html snipet into the DOM with ajax because I have a few navs, one for each section. I got it to load fine but the scrolling jquery nav doesn’t work anymore. The markup in the page is perfect it just no longer works. I am new to all this scripting so there must be something I don’t know in order to make this work. All the proper scripts are waiting for the markup but there seems to be some sort of disconnect. Can anyone help me with this. (loading markup into a page that uses other scripts)
The page is local now so I don’t have a url. If I you need to see the page I can set it up to get this working.
Good to hear you got it working, sorry for the late reply as well. Had a full day at work, try the following. I haven’t tested it but it should work fine
$(document).ready(function(){
// Loading image
var ajax_load = "<div class='loader'><img src='images/load.gif' alt='loading...' /></div>";
// Setup the ajax methods
$.ajaxSetup({
cache: false
});
// Returns the URL based on the class given
var getURL = function(obj){
switch(obj.attr('class').toLowerCase()){
case "identity":
return "identity_nav.html";
break;
case "web":
return "web_nav.html";
break;
case "print":
return "print_nav.html";
break;
case "package":
return "package_nav.html";
break;
default:
return;
}
};
// Run the Ajax query
$(".identity").click(function(){
$("#projectnav").html(ajax_load).load(getURL(this));
});
// END DOCUMENT READY
});
Sorry just say a mistake but still not working. // JavaScript Document $(document).ready(function(){ // Loading image var ajax_load = "
“; // Setup the ajax methods $.ajaxSetup({ cache: false }); // Returns the URL based on the class given var getURL = function(obj){ switch(obj.attr(‘class’).toLowerCase()){ case “identity”: return “identity_nav.html”; break; case “web”: return “web_nav.html”; break; case “print”: return “print_nav.html”; break; case “package”: return “package_nav.html”; break; default: return; } }; // Run the Ajax query $(”.identity").click(function(){ $(“#projectnav”).html(ajax_load).load(getURL(this)); }); // load() functions $(“.web”).click(function(){ $(“#projectnav”).html(ajax_load).load(getURL(this)); }); // load() functions $(“.web”).click(function(){ $(“#projectnav”).html(ajax_load).load(getURL(this)); }); // load() functions $(“.print”).click(function(){ $(“#projectnav”).html(ajax_load).load(getURL(this)); }); // load() functions $(“.package”).click(function(){ $(“#projectnav”).html(ajax_load).load(getURL(this)); }); // END DOCUMENT READY });
Sorry about that, forgot about the jQuery identifiers. You don’t need to declare the same code multiple times as it does the same thing
$(document).ready(function(){
// Loading image
var ajax_load = "<div class='loader'><img src='images/load.gif' alt='loading...' /></div>";
// Setup the ajax methods
$.ajaxSetup({
cache: false
});
// Returns the URL based on the class given
var getURL = function(obj){
switch(obj.attr('class').toLowerCase()){
case "identity":
return "identity_nav.html";
break;
case "web":
return "web_nav.html";
break;
case "print":
return "print_nav.html";
break;
case "package":
return "package_nav.html";
break;
default:
return;
}
};
// Run the Ajax query
$(".identity, .web, .print, .package").click(function(){
$("#projectnav").html(ajax_load).load(getURL(this));
});
// END DOCUMENT READY
});
$(document).ready(function(){
// Loading image
var ajax_load = "<div class='loader'><img src='images/load.gif' alt='loading...' /></div>";
// Setup the ajax methods
$.ajaxSetup({
cache: false
});
// Returns the URL based on the class given (I think this part is the problem)
var getURL = function(obj){
switch(obj.attr('class').toLowerCase()){
case "identity":
return "identity_nav.html";
break;
case "web":
return "web_nav.html";
break;
case "print":
return "print_nav.html";
break;
case "package":
return "package_nav.html";
break;
default:
return;
}
};
$(".identity, .web, .print, .package").click(function(){
$("#projectnav").html(ajax_load).load(getURL(this), function(response){
$(this).html(response).fadeIn(1000);
});
return false;
});
// END DOCUMENT READY
});