We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20892
    • 20 Posts
    Люди добрые помогите! Пытаюсь реализовать AJAX погрузку через jquery. Данные отправляю на index-ajax.php. Вроде jquery запрос правельный а нифига не работает.
    Jquery код такой
    $(document).ready(function(){
    	$("a.menu").click(function(){
    		var type = $(this).attr("id");
    		var location = "assets/snippets/n2_galery/tpl_prevew.php";
    		var sendData = "q="+location+"&type="+type;
    		
    		$.ajax({
    			type: "POST",
    			url: "http://modx/index-ajax.php",
    			data: sendData,
    			beforeSend: waiton(),
    			complete: waitoff(),
    			success: function(result){
    				$(".content").html(result);
       			}
    		});
    	});
    });

    Файл скрипта лежит в папке сниппета.
    В инете рылся но нифига немогу найти. Помогите хто может!!!
      • 16289
      • 121 Posts
      а что именно не работает? Firebug что выдает ?
      У меня лично все работало с запросом:
      $j.ajax({
      					url: "index-ajax.php",             
      					dataType : "html",                    	
      					data: "q=assets/snippets/ajax/ajax.php&id="+id,
      					type: "POST",						
      					success: function(msg){show(msg);}				
      			     });
        How could number of mysql queries be more than number of tables in DB???
        • 20892
        • 20 Posts
        Сам скрипт вмпринципе работает, а именно в среде MODX отказывается
          • 16289
          • 121 Posts
          а что за код сниппета?
            How could number of mysql queries be more than number of tables in DB???
            • 20892
            • 20 Posts
            Там в файле сниппета assets/snippets/n2_galery/tpl_prevew.php 1 строчка кода написана для тестирования
            echo $_POST[’type’];
              • 16289
              • 121 Posts
              Я всегда первую строчку пишу
              header('Content-type: text/html; charset=utf-8',TRUE);

              В Firebug проверяли, идет ли запрос, может у Вас Quick Manager подключает jQuery еще раз и перекрывает вашу функцию?
                How could number of mysql queries be more than number of tables in DB???
                • 20892
                • 20 Posts
                В фаирбаге пишет
                Error thrown at line 20, column 2 in <anonymous function>() in http://modx/assets/snippets/n2_galery/js/ajax.js:
                    $.ajax({
                called from line 55, column 294 in <anonymous function: handle>(a) in http://modx/assets/js/jQuery.js:
                    i=i.handler.apply(this,arguments);
                called via Function.prototype.apply() from line 49, column 569 in <anonymous function: o>() in http://modx/assets/js/jQuery.js:
                    return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w
                Подскажите что это могло бы значить
                  • 16289
                  • 121 Posts
                  предъявите весь код ajax.js, плз smiley
                  А то непонятно, что находится в тех строчках, на которые выбивает ошибка.
                  Prototype и motools отключен?
                    How could number of mysql queries be more than number of tables in DB???
                    • 20892
                    • 20 Posts
                    Текст этого файла в моем первом посте.
                    А где в MODX отключаются эти библиотеки????
                      • 16289
                      • 121 Posts
                      попробуйте так
                      jQuery.noConflict();
                      jQuery(document).ready(function(){
                      	jQuery("a.menu").click(function(){
                      		var type = jQuery(this).attr("id");
                      		var location = "assets/snippets/n2_galery/tpl_prevew.php";
                      		var sendData = "q="+location+"&type="+type;
                      		
                      		jQuery.ajax({
                      			type: "POST",
                      			url: "http://modx/index-ajax.php",
                      			data: sendData,
                      			beforeSend: waiton(),
                      			complete: waitoff(),
                      			success: function(result){
                      				jQuery(".content").html(result);
                         			}
                      		});
                      	});
                      });
                      
                        How could number of mysql queries be more than number of tables in DB???