Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在ajax jquery上为release()获取jcrop对象_Jquery_Ajax_Jcrop - Fatal编程技术网

无法在ajax jquery上为release()获取jcrop对象

无法在ajax jquery上为release()获取jcrop对象,jquery,ajax,jcrop,Jquery,Ajax,Jcrop,各位早上好, 我和这个问题斗争了3个小时,但我找不到赢得XD的方法 我有一个ajax上传,成功后将打开一个twitter引导模式窗口,加载图像,初始化jcrop,然后在关闭时根据选择生成一个拇指库 这个很好用。。。真正的问题是,我需要在模式中发布选择,下面是我按照jcrop网站上的说明所做的捕获,但我无法退出 现在我已经解释了这个问题,是时候编写一些代码了:D var FileUploader_img_frontale = new qq.FileUploader({ 'element':

各位早上好,

我和这个问题斗争了3个小时,但我找不到赢得XD的方法 我有一个ajax上传,成功后将打开一个twitter引导模式窗口,加载图像,初始化jcrop,然后在关闭时根据选择生成一个拇指库

这个很好用。。。真正的问题是,我需要在模式中发布选择,下面是我按照jcrop网站上的说明所做的捕获,但我无法退出

现在我已经解释了这个问题,是时候编写一些代码了:D

var FileUploader_img_frontale = new qq.FileUploader({
    'element':document.getElementById("img_frontale"),
    'debug':false,
    'multiple':false,
    'action':'http://url.com/upload',
    'allowedExtensions':['jpg','png','jpeg','gif'],'sizeLimit':10485760,
    'onComplete':function(id, fileName, responseJSON){ 
          $('#pbar_img_frontale').css('display','none');
      $('#img-front-body').html('<img id="cropbox1" src="url.com/images/tmp/b444ac06613fc8d63795be9ad0beaf55011936ac/'+responseJSON.filename+'" style="max-width:400px;max-height:400px;"/>');

          function showCoordsFront(c){       $('#_opera_img_frontale').val(responseJSON.filename+'|'+c.x+'|'+c.y+'|'+c.x2+'|'+c.y2+'|0'); }
            $('#cropbox1').Jcrop({
                boxHeight: 400,
                boxWidth:400,
                trueSize: [responseJSON.width,responseJSON.height],
                allowResize: true,
                aspectRatio: 4/3,
                onChange: showCoordsFront,
                onSelect: showCoordsFront,
            },function(){ jcrop1 = this; });
            $('#_opera_img_frontale').val(responseJSON.filename);
            front_uploaded=1;
            $('#modal_img_front').modal('toggle');
         },'onProgress':function(id, fileName, loaded, total){ $('#pbar_img_frontale').css('display','block'); $('#bar_img_frontale').css('width',((loaded*100)/total)+'%'); },'params':{'PHPSESSID':'400659255ef857e043b5ab1651406f50','YII_CSRF_TOKEN':'c8248bc34b5371edf162292691dbcf23dc1e697a'}}); 
需要抓取obj,但是当我没有通过ajax上传图像时,它可以工作,我不知道如何处理它,因为释放按钮在jquery ready上未定义jcrop1

var jcrop1;
$("#jcrop1-release").click(function(){
   jcrop1.setSelect([0,0,0,0]);
   jcrop1.release();
});
有人能帮我吗

提前谢谢


法比奥

好了,伙计们,我已经解决了这个问题。。。问题在于脚本的框架管理。。它将放置$(document).ready()的多个实例,因此一个变量在一个中,而ajax在另一个中。。。所以解决方案是绕过document.ready并将全局变量放在外部,这样就可以了


法比奥是不是很复杂?我无法摆脱它,它让我发疯。。。如果我在jcrop1=这个明显返回的对象之后放一个警报,但在那之后,jcrop1似乎消失在稀薄的空气中
var jcrop1;
$("#jcrop1-release").click(function(){
   jcrop1.setSelect([0,0,0,0]);
   jcrop1.release();
});