dqhgjay5753
dqhgjay5753
2014-04-15 12:52

如何手动将POST数据输入浏览器

I'm debugging my php script and need to try to post data to by manually inputting it into the URL in my browser.

The javascript which sends the request is below. How do I enter the correct data into my browser so it's encoded in the same way as the javascript function? I tried encoding the string with http://meyerweb.com/eric/tools/dencoder/ and putting sendmail.php?q="the encoded string"... but that didn't work. Do I have to add more information?

function SendPHP(str, callback){
    xmlhttp = new XMLHttpRequest();  
    str = "q=" + encodeURIComponent(str);

    xmlhttp.open("POST","sendmail.php", true);
    xmlhttp.onreadystatechange=function(){
        if (xmlhttp.readyState == 4){
                      inProgress=false;
            if(xmlhttp.status == 200){
                            callback(xmlhttp.responseText);
            }
        }
    };
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
        if (inProgress==false){
        inProgress=true;
        xmlhttp.send(str);
        }
        else{
            writeDisplayConsole("ERROR: xmlhttp fired twice!");
        }
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

相关推荐