1

我正在使用以下命令将鼠标向下位置发送到控制器中的两个动作,第一个动态制作图像,第二个将图像发送给查看器:

   $("#container2").bind('mousemove', function (e) {
                                currentX = e.pageX;
                                currentY = e.pageY;
                                diffX = (currentX - startX);
                                diffY = (currentY - startY);
                                $.ajax({
                                    url: '/Home/Scale3D',
                                    type: 'POST',
                                    data: {
                                        pX: diffX,
                                        pY: diffY,
                                        pZ: diffX * sThickness,
                                        udm: ++udm
                                    }
                                }).done(function (d) {
                                    image.src = '/Home/Rotate3DImage?udm=' + (++udm);
                               });
                            });

这是第一个动作:

 public ActionResult Scale3D(float pX = 0, float pY = 0, float pZ = 0, int inc = 0)
        {
            DicomImage3D im = null;
           ......
            return Json(new { success = true, inc = inc }, JsonRequestBehavior.AllowGet);
        }

第二个动作:

public ActionResult Rotate3DImage(int udm = 0)
    {
        FileContentResult data;
        ........
        using (var memStream = new MemoryStream())
        {
            objImage.Save(memStream, ImageFormat.Png);
            data = this.File(memStream.GetBuffer(), "image/png");
        }
        return data;
    }

问题是有延迟,有些图像没有显示;在第一个动作处理完所有第一个 ajax 命令之前,第二个动作不会执行。有没有办法在收到成功时执行第二个动作。我会很感激你的建议,在此先感谢。

4

1 回答 1

0
$("#container2").bind('mousemove', function (e) {
                                currentX = e.pageX;
                                currentY = e.pageY;
                                diffX = (currentX - startX);
                                diffY = (currentY - startY);
                                $.ajax({
                                    url: '/Home/Scale3D',
                                    type: 'POST',
                                    data: {
                                        pX: diffX,
                                        pY: diffY,
                                        pZ: diffX * sThickness,
                                        udm: ++udm
                                    },
                                    success: {
                                     // code here
                                     image.src = '/Home/Rotate3DImage?udm=' + (++udm);
                                    }
                                });
                            });
于 2013-05-17T19:00:38.807 回答