douou9786 2011-05-24 12:07
浏览 77

使用Jquery AJAX将Javascript变量传递给PHP

I have the following javascript function

function success_callback(p)
    {

        lat = p.coords.latitude.toFixed(2);
        lon = p.coords.longitude.toFixed(2);

    }

Now I want to transfer both the variable to PHP using Jquery AJAX, I am pretty new to Jquery, I am not able to figure out how to do it. I want to transfer the variables to the same PHP file where this JS code resides. Is that possible ?

  • 写回答

4条回答

  • douyue8364 2011-05-24 12:11
    关注

    Yes it is. You could post the variables using the data string. Have a look at the Manual.

    $.ajax({
      type: "POST",
      data: "lat="+lat+"&lon="+lon,
      success: function(){
          //callback code
          alert("Done!");
      }
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器