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.

    评论

报告相同问题?

悬赏问题

  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?
  • ¥50 invest生境质量模块