在jQuery中执行PHP代码 [英] Execute a PHP code inside jQuery

查看:101
本文介绍了在jQuery中执行PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我所拥有的:

<a href="<?=$arItem["LINK"]?>#nav-link">LinkName</a>

这里<?=$arItem["LINK"]?>我正在获取一些链接,并且我想在此链接的末尾添加一些额外的井号标签参数#nav-link.

Here <?=$arItem["LINK"]?> I'm getting some link, and I want to add to the end of this link some extra hashtag parameter #nav-link.

但是主要问题是PHP在服务器端执行,因此,当我单击链接时,仅从<?=$arItem["LINK"]?>(blabla.com)获得链接.第二次单击后,我得到了必要的代码blabla.com/#nav-link.

But the main problem is that PHP is executing on the server side, so, when I click the link, I get only link from the <?=$arItem["LINK"]?> (blabla.com). After second click, I have necessary code blabla.com/#nav-link.

那么,第一次单击后能否获得blabla.com/#nav-link?

So, is it possible to get blabla.com/#nav-link after first click?

推荐答案

尝试一些与此类似的事情:

Try something to the tune of this:

<script>
  var data = <?php echo $arItem["LINK"]; ?>

  var yourLink = "blabla.com/"+data;

  //more of your code etc....

  $('#yourDiv_where_you_want_the_link').html(yourLink);

 </script>

这篇关于在jQuery中执行PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆