doubian19900911 2014-10-01 14:19
浏览 34

如何从不同的页面发送字符串作为POST数据?

I have a search page with an input box in my index.php. The form is using POST method.

<form id="someID" action="result.php" method="post">
    <input name="name" id="name" type="text">
    <input type="submit" value="Search">
</form>

Now I want to send a string to that input box from result.php page using a link like this-

<a href="javascript:void(0)">Some Name</a>

I can get the content of this link using JS and can send the name to result page if I use GET method.
Example: http://example.com/result.php?name=value

But I cannot use GET here.
Can I send the content of this link as a string to the result page using POST method? Any ideas?

  • 写回答

2条回答 默认 最新

  • drt41563 2014-10-01 14:23
    关注

    If you're using jQuery (to make AJAX simpler than vanilla JS) it would look like this:

    $.post('http://example.com/result.php', { name: value }, function(data) {
        // data -> returned HTTP request
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败