2012-04-14 140 views
0

這個Ajax請求有效,但它似乎沒有發佈到getHint.php($_POST['targetId']爲空)。任何想法我做錯了什麼?沒有發佈Ajax請求的參數

非常感謝

postAjaxRequestFunktion(minFunktion, 'getHint.php', 'targetId = ' + playId) 

     function postAjaxRequestFunktion(minFunk,minUrl, mittArg) 
     { 
      var contenttype = 'application/x-www-form-urlencoded' 
      var minRequest  = new skapaAjaxObjekt(minFunk) 
      if (!minRequest) return false 
      minRequest.open('POST', minUrl, true) 
      minRequest.setRequestHeader('Content-type', contenttype) 
      minRequest.setRequestHeader('Content-length', mittArg.length) 
      minRequest.setRequestHeader('Connection',  'close') 
      minRequest.send(mittArg) 
      return true 
     } 


     function skapaAjaxObjekt(minFunk) 
     { 
      try  { var minRequest = new XMLHttpRequest()     } 
      catch(e1) { try { minRequest = new ActiveXObject("Msxml2.XMLHTTP") } 
      catch(e2) { try { minRequest = new ActiveXObject("Microsoft.XMLHTTP") } 
      catch(e3) { minRequest = false }}} 
      if (minRequest) minRequest.onreadystatechange = function() 
      { 
       if (this.readyState == 4 && this.status == 200 && 
        this.responseText != null) 
        minFunk.call(this.responseText) 
      } 

      return minRequest 
     } 

     function minFunktion() 
     { 
      hintArray = eval('(' + this + ')');  
     } 

getHint.php:

$targetId = $_POST['targetId']; 
+0

你能告訴我們你的HTML嗎? – Lion 2012-04-14 13:34:07

+0

我不確定你需要看什麼HTML? – Fred 2012-04-14 13:42:56

回答

1

我建議你使用一個js的lib jQuery的地方Ajax請求更簡單.. 也是在php文件使用 的var_dump( $ _ POST); 會給你更多的信息

+0

謝謝你,jQuery要容易得多。 – Fred 2012-04-15 07:17:59