4

index.htmlサーバーtest1.comからファイルを実行しています。Mootools ライブラリ ファイルは、このindex.htmlファイルに含まれています。

以下は、PHP ページを呼び出すスクリプトです。

<script>
  var request = new Request.JSON({
    url: 'http://test1.com/ajaxtest.php',
    onSuccess: function(data) {
      // the request was completed.
      alert(JSON.stringify(data));
    }
  }).send();
</script>

ajaxtest.php

<?php
  $arr['age'] = 30;
  $arr['place'] = 'London';
  echo json_encode($arr); exit;
?>

の実行中index.htmlに、正しい出力が得られます」

{"年齢":30,"場所":"ロンドン"}

現在、ajaxtest.phptest2.com などの別のサーバーに常駐しています。上記のスクリプトを以前と同じように変更するにはどうすればよいですか?

4

1 に答える 1