cUrl转换为Javascript可能?

问题描述:

有没有办法将它转换为javascript?

is there a way to convert this into javascript?

  <?php
      $url = 'http://www.yourdomain.com/';
      $ch = curl_init();

      curl_setopt($ch, CURLOPT_URL, $url); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
      $output = curl_exec($ch); 
      curl_close($ch);

      echo $output;
    ?>


否。

使用标准浏览器环境的JavaScript?也许。有 XHR对象(其中包括状态属性,它会告诉您是否成功),但也有同一来源政策

JavaScript with a standard browser environment? Maybe. There is the XHR object (which includes the status property, which will tell you if it was successful or not), but there is also the same origin policy.