duanping3587 2014-02-05 12:48
浏览 60

来自javascript提示的回显变量[重复]

This question already has an answer here:

I am struggling to get the following code to work. I want to take input from a javascript prompt, and output it using a php echo. When I try this I get an echo with the random numbers "12313" for no apparent reason. This is my code:

echo '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>'
   , '<script type="text/javascript">'
   , 'var code = prompt("Enter verification code", "");'
   , 'var getcode = code;'
   , '$.post("wp-members-register.php", { code: getcode }); </script>';

     $buffer_data['code'] = $_POST['code'];
    echo $buffer_data['code'];

I am very new to php so please bear with me. Perhaps I am not correctly posting the 'code' variable?

EDIT: Maybe somebody can show me a better way of inputting a text string and getting it in the php code to follow? Note I am working with the wp-members wordpress plugin in the wp-members-register.php file.

</div>
  • 写回答

2条回答 默认 最新

  • duanqiao1926 2014-02-05 12:54
    关注

    Outputting javascript using PHP doesn't make any sense as javascript is a client side scripting which is executed after loading the DOM elements. PHP code is triggered when the request is sent from the browser to the server.

    评论

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 关于#网络安全#的问题:求ensp的网络安全,不要步骤要完成版文件
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥20 使用Photon PUN2解决游戏得分同步的问题
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序