dongtui2029 2013-12-27 16:58 采纳率: 0%
浏览 38

如何在azure网站上将变量从javascript发送到PHP?

To simplify the problem, all I want is passing 3 variable from javascript to PHP. So let say I have 4 varible : a,b,c,message.

I have tried the following ways:

1)The code below is in my javascript file

window.location.href="somewebsite.php?x=" + a + "&y=" + b + "&z=" + c + "&msg=" + message;

I saw that it actually passing the values to URL, it jump to the PHP website that specifies in the code above but somehow nothing is getting from $_POST['x'] ( I even try $_GET['x'] and $_REQUEST('x') but none of them works at all)

2) Then I tried with ajax

$.post("somewebsite.php",{x:a, y:b, z:c, msg:message})

And same as above nothing are passed to the PHP website.

3) I tried with form submit I put everything into a form and submit it to the PHP website but what I get from $_POST is an empty array.

So I conclude that something is wrong with azurewebsites server. This is the first time I used window azure so I don't know how it even works. Any suggestion would be appreciated.

  • 写回答

3条回答 默认 最新

  • duannai5858 2013-12-27 17:07
    关注

    you can try out ajax function

    $.ajax({
                        url:"url",
                        method:"post",
                        data:{x:a, y:b, z:c, msg:message},
                        success:function(data)
                        {
                         // success code 
    
                        },
                        error:function(error)
                        {
                          // error code ;
                        }
    
              });
    
    评论

报告相同问题?

悬赏问题

  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题