douyong1974 2015-07-03 17:40
浏览 54
已采纳

调试名为jQuery的PHP脚本

I have a web app that in which I have a jQuery call to a PHP script that returns JSON.

When I run the PHP script from the jQuery call I get one result but when I run the PHP script from the web address I get a different result.

I think when I send the variables through the jQuery call:

$.post("http://myweb.php", {
            u: u,
            j: j
        })
        .done(function (data) {


            alert(data.status );
            //alert("Data Loaded: " + data);
        });

Something is getting appended to them. Because like I said earlier when I simply put in my browser:

myweb.php?u=m&j=e

I get the correct results from the MySQL call that is made.

I am trying to see what I run for my MySQL call when the jQuery is run but I am having trouble debugging the PHP script that is called. I put this line of code in the PHP:

console.log($query);

But I am not seeing its output or maybe I am looking in the wrong place in chrome for it...

  • 写回答

2条回答 默认 最新

  • douchixu3686 2015-07-03 17:46
    关注

    Notice that in your jQuery call you are using "post" and when checking it from browser, it is done by "get", so that might be one of the issues.

    How are you getting the variables in PHP? ($_GET | $_POST | $_REQUEST)?
    Try by changing your jQuery ajax call to do it through GET instead POST.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?