2013-07-18 40 views
0

我嘗試通過ajax發送一個簡單的字符串,但php GET var爲null。謝謝Ajax GET但php變量爲空

function postJSON(){ 
$.ajax({ 
type: "GET", 
url: "http://www.my-server.de/file.php", 
data: { 'dataString': "juhu" }, 
cache: false, 
success: function() 
    { 
     alert("Order Submitted"); 
    }, 
    error: function() 
    { 
     alert("Error"); 
    } 
}); 

PHP:

<?php 
echo "Value is:"; 
echo $_GET['dataString']; ?> 
+0

看到控制檯的任何錯誤.. –

+2

@ShuklaJay爲什麼。 – iConnor

+0

你會得到什麼結果,你期望得到什麼結果? – meiamsome

回答

2

也許你應該試試這個

$.ajax({ 
    type: "GET", 
    url: "http://www.my-server.de/file.php", 
    data: { 'dataString': "juhu" }, 
    cache: false, 
    success: function(response){ 
     alert(response); 
    }, 
    error: function() { 
     alert("Error"); 
    } 
}); 
+0

謝謝, 現在我得到了我的android手機上的警報框中的PHP輸出,但是這輸出應該是**在網頁**;) – user2289728

+0

那麼,這不是你的問題,你的問題是爲什麼你沒有得到結果,並且解決了。嘗試在這裏http://chat.stackoverflow.com/rooms/29074/html-css-dom-webdesign,你需要獲得20代表,雖然 – iConnor