好吧,我正在尝试的是在使用JQuery的HTML页面中复制相同的功能以从我的数据库中将页面产品拉入。Jquery复制PHP效果
这个过程中,你有你的典型的PHP调用数据库的PHP版本中目前连接:
<?php
define('INCLUDE_CHECK',1);
require "connect.php";
?>
现在有这个过程的一个部分,使得对DB的调用和拉动产品和echo将div和img标签与分配给适当区域的信息分开。
<?php
$result = mysql_query("SELECT * FROM internet_shop");
while($row=mysql_fetch_assoc($result))
{
echo '<div class="product"><img src="img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></div>';
}
?>
现在还有一些其他脚本可以识别出这些信息并将工具提示应用于产品并使其可拖动。在PHP页面内完成此工作时它工作正常。
现在我正在试图让这个做同样的事情是在我的html页面中使用.ajax()调用。
var grbData = $.ajax({
type : "GET",
url : "getRow.php",
dataType: 'html',
success: function (html) {
$(".product").html(html);
},
error: function (xhr) {
$('#errorDisplay').html('Error: '+ xhr.status +'' +xhr.statusText);
}
});
我得到的图像来横跨,但没有得到可拖动和droppable效果适用于这些产品。我不是在提供我需要的所有信息吗?
这里是拖放脚本与此过程一起工作:
$(document).ready(function(){
var xhr;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}else if (window.ActiveXObject) {
xhr = new ActiveXObject("sxml2.XMLHTTP");
}else {
throw new Error("Ajax is not supported by this browser");
}
$(".product img").draggable({
containment: 'document',
opacity: 0.6,
revert: 'invalid',
helper: 'clone',
zIndex: 100
});
$("div.content.drop-here").droppable({
drop:
function(e, ui)
{
var param = $(ui.draggable).attr('src');
if($.browser.msie && $.browser.version=='6.0')
{
param = $(ui.draggable).attr('style').match(/src=\"([^\"]+)\"/);
param = param[1];
}
addlist(param);
}
});
});
感谢,
马特
在哪里可拖动/可弃脚本? – David 2010-02-10 16:43:39
我刚刚添加了拖放脚本 – TikaL13 2010-02-10 17:18:02