Не происходит перезагрузка
Подскажите пожалуйста как суда
function addlist(param) { $.ajax({ url: 'index.php', data: 'drop='+encodeURIComponent(param)+'&process='+ encodeURIComponent(document.getElementById('process').value), type: 'POST', dataType: 'json', success: function (result){alert (result);} }); } добавить перезагрузку как в обычном XMLHttpRequest function Refresh() { if(req.readyState == 4 && req.status == 200) ge('pageContent').innerHTML = req.responseText; } Данные отсылает но не происходит перезагрузка страницы, по идее это должна делать success:, но не могу ее изменить |
перезагрузку данных ?
Тогда так: $('#pageContent').html(result); |
Нет все равно не получается. Ну вот например есть такая форма
<div id='pageContent'> <input name="process" id="process" value="1" type="hidden" /> <input name="more" id="more" value="1" type="hidden" /> <a href="#" onClick="test();">Link</a> </div> А вот js код function test() { $.ajax({ url: 'index.php', data: 'more='+encodeURIComponent(document.getElementById('more').value)+'&process='+ encodeURIComponent(document.getElementById('process').value), type: 'POST', dataType: 'json', success: function (result){alert (result);} }); } Данные отправляются но не происходит сама перезагрузка страницы, там php файл принимает данные и обрабатывает, но результат виден после ручного рефреша. |
Вот так получилось
function addlist(param) { $.ajax({ url: 'Process.php', data: 'drop='+encodeURIComponent(param)+'&process='+ encodeURIComponent(document.getElementById('process').value), type: 'POST', dataType: 'php', success: function(msg) { if(parseInt(msg)!=0) { $('#pageContent').html(msg); } } }); } |
Возникла еще одна проблема. Вот скрипт который делает сортировку у перетаскивание с добавлением в базу, проблема в том что после первого действия скрипт перестаёт работать, после первого запроса уже не отсылается, вроде firebug ничего не показал
var dropped = false; var templateHtml; $(document).ready(function(){ function addlist(param) { $.ajax({ url: 'index.php', data: 'drop='+encodeURIComponent(param), type: 'POST', dataType: 'php', success: function(msg) { if(parseInt(msg)!=0) { $('#pageContent').html(msg); } } }); } setSortable(); $("#droppable").droppable({ accept:".drop", drop:function(event,ui){ dropped = true; addlist(ui.draggable.text()); } }); }); function setSortable(){ $("#sortable").sortable({ opacity: 0.6, cursor: 'move', update: function() { var order = $(this).sortable("serialize") + '&action=listing'; $.post("index.php", order, function(theResponse){ $("#pageContent").html(theResponse); }); } }); $("#sortable li").addClass("drop").bind('mousedown',function(){ templateHtml = $("#sortable").html(); }); } <div id="pageContent"> <ul id="sortable"> <li id="one">One</li> <li id="two">Two</li> <li id="three">Three</li> <li id="four">Four</li> <li id="five">Five</li> <li id="six">Six</li> </ul> <div id="droppable"> </div> </div> |
Часовой пояс GMT +3, время: 21:29. |