duandeng7132 2014-08-09 14:20
浏览 31
已采纳

如何通过单击标记来更改PHP变量

I just want use ajax to change some variables in PHP code, I search so long time and dont get answers.

there is a a variable which called $args, it's an array,

$arg=array(
    'paged' => $paged,
    'author'=> $author_ID,
    'showposts'=>  $author_posts_num,
    'post_status'=>'publish'
)

and I want to click on a tag, change some variables or add some to $arg,I know PHP is compiles on the server, but what I though is can I change the the variable above before the server compile php code, I mean is this possible: 1:click the tag(maybe a button) 2: change variable above 3: the server compile PHP 4: hte HTML page reload 5: and we see the HTML page has changed

I just new to PHP AJAX, so a little confused here, thank you so much

  • 写回答

3条回答 默认 最新

  • dongzai5181 2014-08-09 14:24
    关注

    I just want use ajax … can I change the the variable above before the server compile php code

    No. If you are using Ajax, then this is what happens:

    1. Browser requests URL
    2. Server runs PHP and sends the output to the browser
    3. Browser runs JavaScript
    4. JavaScript tells browser to request another URL
    5. Server runs PHP and sends the output to the browser
    6. JavaScript can do something with the result

    hte HTML page reload

    If you want to reload the page: Don't use Ajax. The entire point of Ajax is to get new content from the server without reloading the page.

    Just submit a form to the server and have PHP run and deliver a new page based on the user inform from the form submission.

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

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题