随着我的框架的增长,我决定将其拆分为文件,而不是将其留在主设计文件中.但是,通过这样做,函数的返回不会返回任何值.
数据不为空 - 如果我警告js文件中的值,它们就在那里!
功能:
第一个.js文件中的函数(在执行之前包含)
var lock_get = 0;
function get_data(data, destination)
{
if (lock_get == 0)
{
lock_get = 1;
$.ajax({
type: "POST",
url: destination,
async: true,
data: data,
success: function(data)
{
lock_get = 0;
if (data)
{
return data;
}
}
});
}
};
Run Code Online (Sandbox Code Playgroud)
所以这里是执行部分:
var test = get_data(data, destination);
notice(test);
Run Code Online (Sandbox Code Playgroud)
并且测试是空的...我已经尝试了不同的写作方式,但我想我错过了js的可能性?
好吧,它变得尴尬,已经搜索并尝试了大约5个小时,我只是在圈子里跑...
场景很简单:它是用户配置文件的标题图像,可以将其拖动到某个位置,然后将图像的顶部位置保存到数据库中.
感谢Beetroot-Beetroot的"遏制:'父母'"我对这段代码感兴趣,实际上我想要它做出反应!除了一个大问题.图片只是跳到顶部或底部.没有平滑的滚动?如果我将"父母"改为"父母",它会很好地滚动但是...当然遏制不再存在了.救命?:d
JS
$(function(){
$(".headerimage").css('cursor','s-resize');
$(".headerimage").draggable({ containment: 'parent', scroll: false, axis: "y", stop: function(event, ui) {
var data = "profileheaderposition="+ui.position.top;
var destination = "/modules/users/profile/save.php";
get_data(data, destination, function(test){
notice(test);
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
所以最后但并非最不重要的是,Header包括在内:
<div class="<?php if ($user->id == $profileuser->id) echo "changer"; ?> ui-corner-all" id="profileheader" style="overflow: hidden; width: 650px; height: 260px; position:relative;">
<?php if($profile->profileheader){
$size = getimagesize($profile->profileheader);
?>
<img id="" class="draggable headerimage" style="position: absolute; top: <?php echo $profile->profileheaderposition; ?>px;" src="<?php echo $profile->profileheader; ?>" alt="profileheader" width="650" />
Run Code Online (Sandbox Code Playgroud)
正如我所说,几个小时的谷歌搜索没有给出任何结果 - 如果我不保存结果它会工作得很好,但哦,好吧......
- …