0

此 Ajax 请求有效,但似乎参数未发布到 getHint.php ($_POST['targetId']为空)。任何想法我做错了什么?

非常感谢

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'];
4

1 回答 1

1

我建议您使用 js lib jQuery,其中 ajax 请求更简单.. 也在 php 文件中使用 var_dump($_POST); 会给你更多信息

于 2012-04-14T13:37:25.100 回答