dst2007 2013-06-03 07:22
浏览 32
已采纳

PHP&js / jquery:点击[关闭]如何运行PHP代码

How can I run PHP code on click of a link? (<a>link here</a>)?

I know how listen for a click in JavaScript or JQuery And then perform JavaScript or JQuery, but how would I do PHP?

  • 写回答

2条回答 默认 最新

  • dq13733519262 2013-06-03 07:27
    关注

    PHP code is a server side code while JavaScript is a client side. Thus PHP code executes on the server while JS code executes in client's browser. There are no way to execute PHP code in client's browser but what you've probably needs is AJAX.

    AJAX requests can be called from client's browser to run some custom server side code which will return the result to browser. The way to do it from jQuery is using $.ajax() method or one of it variants - $.post() and $.get().

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料