2016-09-19 76 views
-1

在试图找出为什么我无法使用CasperJS发送AJAX请求后,我很沮丧。我遵循官方文件,试图找出自己,但没有运气。CasperJS - 发送AJAX请求并处理它们的正确方法

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

这是我的一个尝试,我会感谢任何帮助。

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

+0

我想我知道问题是什么,但是您应该展示一个更大的代码示例来确保。请相应地编辑你的问题。看来你还没有阅读过足够的文档。 –

回答

0

您是否尝试过与评价?

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