繁体   English   中英

CasperJS - 发送 AJAX 请求并处理它们的正确方法

[英]CasperJS - The proper way to send AJAX request and handle them

在试图弄清楚为什么我无法使用 CasperJS 发送 AJAX 请求后,我感到很沮丧。 我遵循了官方文档,试图弄清楚自己,但是没有运气。

我的应用程序需要向服务器发送一个包含 2 张图像名称的数组的 AJAX,结果必须是一个字符串。

这是我的尝试之一,我将不胜感激。

 // idx is the index number of current picture. The images without extension as they are processed on server side function getCalcResult() { return JSON.parse(__utils__.sendAJAX('http://localhost:8081', 'GET', {'img1': 'screenshot' + idx, 'img2': 'Expected_' + idx}, false)); }

你试过评估吗?

function getCalcResult()
{
  return JSON.parse( 
        casper.evaluate(function(){
          return __utils__.sendAJAX('http://localhost:8081', 'GET', {'img1': 'screenshot' + idx, 'img2': 'Expected_' + idx}, false);
        }
    );
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM