【问题标题】:How to submit data to external website using JSON /JQUery and get the results and display in my JSP page如何使用 JSON /JQUery 向外部网站提交数据并获取结果并显示在我的 JSP 页面中
【发布时间】:2013-12-27 07:35:41
【问题描述】:

我是 json 和 JQuery 的新手,用于从外部 URL 剪辑 html 元素。我尝试阅读几本书,但没有从哪里以及如何开始。

我需要的例子。

我有一个带有文本字段和按钮的 jsp 页面,我输入了“java 教程”并单击按钮。然后它应该转到 google.com 并将字符串粘贴到文本字段中,然后单击 google serach。谁能帮助我如何使用 json 和 jquery 来实现。

提前致谢。 斯里坎特。

【问题讨论】:

标签: java javascript jquery json


【解决方案1】:

您不需要 JSON 数据即可将您的输入信息提交到 google 搜索页面。我的意思是你不应该去谷歌页面输入数据到搜索框然后点击搜索。你应该做的是将用户重定向到谷歌,如下所示:

在 DOM 准备好后的 jquery 中

$(document).ready(function()
{
    $('#submit').click(function()
    {
        window.location.href='https://google.com/?q='+$('#query_data').val();
    });
});

HTML 如下(在表单标签内):

<input type="text" id="query_data">
<input type="button" id="submit" value="Submit">

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    • 2015-06-16
    相关资源
    最近更新 更多