如何解决与jQuery Drag n Drop排名的Ajax冲突? [英] How do I fix an Ajax conflict with jQuery Drag n Drop ranking?

查看:135
本文介绍了如何解决与jQuery Drag n Drop排名的Ajax冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两组代码

I have two sets of code Loadmore Button And Jqueury Drag N Drop but they do not work as one.

如何将它们合并在一起以充当一个代码?

How can I merge them together to function as one code?

这是问题所在:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
type="text/javascript">

Loadmore按钮需要此行,它会终止拖放元素的UI功能.

This Line is needed by the Loadmore Button and kills the UI function of the Drag and Drop elements.

拖放N点:

<title>jQuery Dynamic Drag'n Drop</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.7.1.custom.min.js">

</script><script type="text/javascript">
  $(document).ready(function(){ 

$(function() {
    $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
        var order = $(this).sortable("serialize") + '&action=updateRecordsListings'; 
        $.post("updateDB.php", order, function(theResponse){
            $("#contentRight").html(theResponse);
        });                                                              
    }                                 
    });
});

}); 
</script>

DND updateDB.php

DND updateDB.php

<?php 
require("db.php");

    $action                 = mysql_real_escape_string($_POST['action']); 
    $updateRecordsArray     = $_POST['recordsArray'];

if ($action == "updateRecordsListings"){

$listingCounter = 1;
foreach ($updateRecordsArray as $recordIDValue) {

    $query = "UPDATE records SET recordListingID = " . $listingCounter . " WHERE recordID = " . $recordIDValue;
    mysql_query($query) or die('Error, insert query failed');
    $listingCounter = $listingCounter + 1;  
}

echo '<pre>';
print_r($updateRecordsArray);
echo '</pre>';
echo 'If you refresh the page, you will see that records will stay just as you modified.';
}?>

DND主PHP:

    <ul>
    <?php
            $query  = "SELECT * FROM records ORDER BY recordListingID ASC";
            $result = mysql_query($query);

            while($row = mysql_fetch_array($result, MYSQL_ASSOC))
            {
            ?>
                <li id="recordsArray_<?php echo $row['recordID']; ?>"><?php echo $row['recordID'] . ". " . $row['recordText']; ?></li>
            <?php } ?>
        </ul>


Loadmore:


Loadmore:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
type="text/javascript"></script>

<script>
$(function() {
var page = 1;
$("#LoadMore").click(function(){
    $.ajax({
        type:"GET",
        url:"page4.php",
        data:{page:page},
        success: function(response) {
            $("#data_grid").append(response); 
            page++;
        }
    });
}); 
});</script>

Loadmore page4.php

Loadmore page4.php

<?php
//set argument as your mysql server
$connect = mysql_connect("mysql_server","mysql_user","mysql_password");
mysql_select_db("database_name",$connect);

$page = isset($_GET["page"]) ? $_GET["page"] : 1;
$limit = 25;
$offset = ($page - 1) * $limit;

$sql = "SELECT * FROM table2 limit $offset, $limit";
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
if($numRows>0) {
    while($row = mysql_fetch_array($result)) {
        //get field data and set to the following row
        echo "<tr><td>field 1</td><td>field 2</td><td>field 3</td></tr>";
                //edit row as you table data

    }
} else {
    echo "<tr><td colspan='3'> No more data </td></tr>";
}
exit;
?>

我想念什么?我可以解决这个问题吗?我是否必须取消Jquery Drag N Drop?我应该使用替代方法吗?

What am I missing? Can I fix this? Am I going to have to scrap the Jquery Drag N Drop? Is there an alternative that I should be using?

背景:用户将按照他们认为合适的顺序对所列项目进行评分.可能的项目总数超过300,000,但用户可能只使用前几百,而其余的则用作可搜索的数据库,以将奇数项目添加到列表中.我可以将有问题的2个代码分开工作,但是当我尝试将它们组合使用时会产生冲突.

Background: A user will rate listed items in the order they deem fit. The total possible Items exceed 300,000 but the user will probably only utilize the first few hundred and the rest is used as a searchable database to add an odd item into the list. I can get the 2 codes in question to work separately but when I attempt the combination they create conflict.

感谢您的时间来协助这个项目.

Thank you for your time in assisting this project.

推荐答案

查看此处

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
    type="text/javascript">

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>

相同(jQuery文件)

are same (jQuery file)

所以只能使用一个

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"
    type="text/javascript">

这篇关于如何解决与jQuery Drag n Drop排名的Ajax冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆