2011-04-20 95 views
1

低於AJAX請求的目的的jquery AJAX問題是簡單真的,只是發送2個變量從127.0.0.1www.example.com/remoteScript.php文件這是在遠程服務器。到目前爲止,它在Safari,Firefox和Chrome中運行得非常好(www.example.com/remoteScript.php文件從127.0.0.1獲取數據並將其存儲到數據庫中)。與IE歌劇

但是,當我在IE7,IE8,IE9或Opera中運行ajax時,remoteScript.php似乎沒有收到任何數據。有什麼建議麼? :)

這是我的HTML的一部分(位於:127.0.0.1)的我 「externalJS.js」(位於:127.0.0.1

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Statistics</title> 


<script language="javascript" src="jquery-1.5.1.js"></script> 
<script language="javascript" src="externalJS.js"></script> 

<script type="text/javascript"> 
    initCI(); //function is located in externalJS.js 
</script> 
</head> 

部分

function initCI() 
{ 
    variable1 = "a string"; 
    variable2 = "a string"; 
    $(function(){ 
     $.ajax({ 
      url: "http://www.example.com/remoteScript.php?variable1="+variable1+"&variable2="+variable2, 
      type: "GET", 
     }); 
    }); 
} 

remoteScript.php(位於:www.example.com

<?php 
    $variable1= $_GET["variable1"]; 
    $variable2= $_GET["variable2"]; 
    store variables to database... 
?> 
+1

閱讀[相同來源政策](http://en.wikipedia.org/wiki/Same_origin_policy)... – prodigitalson 2011-04-20 01:08:36

回答

0

可能有一個原因,你不這樣做,但我已經做了類似的使用$ .post或$ .get函數而不是$ .ajax函數。這看起來像你的例子如下:

function initCI() 
{ 
    variable1 = "a string"; 
    variable2 = "a string"; 
    $.get('www.example.com/remoteScript.php',{ 'variable1':variable1,'variable2':variable2 }); 
} 

你也可以做用「數據」屬性,而不是手動將數據序列化到URL中的$就功能類似的東西。

以下鏈接可能在使用$功能AJAX會有所幫助:

的$就功能本身有很多的內置功能,可能會幫助你。