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 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂