weixin_33698043 2014-05-09 12:11 采纳率: 0%
浏览 6

Ajax和动态网址

I have been following a tutorial on javascript and php and modifying it to my own personal tastes. I've run into something i dont know how to fix, and i cant find anything online to help me fix it either.

The tutorial in question has shown me how to create and ajax module i can call from any php script to do its bidding. however the tutorial simply had the ordinary file paths of "index.php" or "signup.php", but i went ahead and out of my own personal preference, i used $_GET includes to display my pages via "index.php?page=signup"

the tutorial ajax module is:

function ajaxObj( meth, url ) {
    var x = new XMLHttpRequest();
    x.open( meth, url, true );
    x.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    return x;
}
function ajaxReturn(x){
    if(x.readyState == 4 && x.status == 200){
        return true;    
    }
}

now when i use a form to call this function to send data to php, it just sends me back to index.php without the dynamic url in place. im not sure what i need to place into the function call. the tutorial had:

var ajax = ajaxObj("POST", "signup.php");

I just dont know what to use besides "signup.php in the case of having the url being index.php?page=signup but nothing i've tried seems to work, and im starting to question if the error actually has anything to do with the ajax function.

Please assist a nooby noob in this dilemma.

  • 写回答

0条回答 默认 最新

      报告相同问题?

      悬赏问题

      • ¥15 虚拟机vmnet8 nat模式可以ping通主机,主机也能ping通虚拟机,但是vmnet8一直未识别怎么解决,其次诊断结果就是默认网关不可用
      • ¥20 求各位能用我能理解的话回答超级简单的一些问题
      • ¥15 yolov5双目识别输出坐标代码报错
      • ¥15 这个代码有什么语法错误
      • ¥15 给予STM32按键中断与串口通信
      • ¥15 使用QT实现can通信
      • ¥15 关于sp验证的一些东西,求告知如何解决,
      • ¥35 关于#javascript#的问题:但是我写的只能接码数字和字符,帮我写一个解码JS问题
      • ¥15 prophet运行报错,如何解决?
      • ¥15 用GPU跑pytorch搭建的LSTM的时候出现了奇怪的报错