Hi, i have website that retrieves his main content using ajax.
The problem is that whenever i include the jquery ui library into the main page(the static one, where all the dynamic content is loaded inside a div) the ajax script doesn't work anymore.
The console doesn't give any error and there're no ajax requests.
The load order of the main page is:
jQuery
jQuery ui
<html content>(including the div where the content is loaded)
ajax script
If i include the jquery ui script at the end of the content that gets loaded, the ajax script works only once and the jquery ui widget works on that content but besides that the ajax script doesn't load any other content(doesn't even starts a request when clicking on menu's entries).
This is the ajax script i wrote:
- $(function() {
- var newHash = "",
- $mainContent = $("#mainContent"),
- $pageWrap = $("#contentCenter"),
- $mainMenu = $("#topMenu li a"),
- baseHeight = 0,
- $el;
-
- $pageWrap.height($pageWrap.height());
- baseHeight = $pageWrap.height() - $mainContent.height();
-
- $mainMenu.on("click", function() {
- window.location.hash = $(this).attr("href");
- return false;
- });
-
- $(window).bind('hashchange', function(){
-
- newHash = window.location.hash.substring(1);
-
- if (newHash) {
- $mainContent
- .fadeOut(200, function() {
- $mainContent.hide(function() {
- $(".loader").show();
- var page = newHash;
- var data = 'page=' + page;
- $.ajax({
- url: "main_content/action.php",
- type: "POST",
- data: data + "&request=ajax",
- cache: false,
- success: function (html) {
- $mainContent.html(html);
- if ($mainContent.find("img").length > 0) {
- $("#mainContent img").on('load', function() {
- $(".loader").hide();
- $mainContent.fadeIn(200, function() {
- $pageWrap.animate({
- height: baseHeight + $mainContent.height() + "px"
- }, 300, function(){
- $pageWrap.css("height", "auto");
- });
- });
-
- $mainMenu.removeClass('selected');
- $('a[href="' + newHash + '"]').addClass('selected');
- return false
-
-
- });
- }
-
- else {
-
- //$(".loader").hide();
- $mainContent.fadeIn(200, function() {
- $pageWrap.animate({
- height: baseHeight + $mainContent.height() + "px"
- }, 300, function(){
- $pageWrap.css("height", "auto");
- });
- });
-
- $mainMenu.removeClass('selected');
- $('a[href="' + newHash + '"]').addClass('selected');
- return false
-
- }
- }
- });
- });
- });
- };
-
- });
-
- $(window).trigger('hashchange');
- });
I saw that when including jQuery ui at the end of the loaded content the jQuery ui script sends a request that looks like this:
is that normal?
Any suggestions on how to solve the problem? Thanks