开发者

clean $_GET var which was used in ajax

I'm sending $.ajax to worker.php with this "data:pageref=streets&act=vw". When I make echo of $_GET['vw']. I getting another value from different $_GET variable which w开发者_高级运维as sent to worker php using ajax a long time ago. How I should fix this? the first idea is to clean $_GET elements. any suggestions?

function ref() {
        //

        $.ajax({
                type: "GET",
                url: "worker.php",
                data: "pageref=streets&act=vw",
                success: function(msg){
                    document.getElementById('main_street_res').innerHTML=msg;
                }
            });
    }


You should echo $_GET['act'] instead of $_GET['vw'] This is the probable error for getting junk values.


You try to echo $_GET['vw'] ?

In data you pass pageref=streets&act=vw, so there are two keys: pageref and act.

If you echo $_GET['act'] you will get vw - it does not work in the other way.


You are getting so because you are doing echo to wrong variable. your variable is in $_GET['act'] not in $_GET['vw'].


I assume you are getting a cached version of worker because you are not sending the data correctly, therefore the address is just worker.php. I think the data should be sent as an object like this:

data: { pageref: 'streets', act: 'vw' },
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜