jsonp 百度搜索框

JSONP跨域实现百度搜索功能(v1.0.0) 原生Js利用Jsonp跨域实现百度搜索功能 立即下载

转载于:https://www.cnblogs.com/xiaohuochai/p/6568039.html

<style>
body{margin: 0;}
ul{margin: 0;padding: 0;list-style: none;}
a{color:inherit;text-decoration: none;}
input{padding: 0;border: 0;}
.box{width: 340px;height: 38px;border: 2px solid gray;}
.con{overflow: hidden;}
.input{float: left;width: 300px;height: 38px;}
.search{width: 38px;height: 38px;float: right;background: url('http://sandbox.runjs.cn/uploads/rs/26/ddzmgynp/search.png') 0 -38px;}
.list{position: absolute;width: 298px;border: 1px solid #e6e8e9; overflow: hidden;}
.in{line-height: 30px;border-bottom: 1px solid lightblue;cursor:pointer;text-indent: 1em;}
.list .in:last-child{margin-bottom: -1px;}
.in:hover{background-color: #f9f9f9;}
</style>

<div class="box" id="box">
    <div class="con">
        <input class="input" id="search">
        <a target="_blank" id="btn" href="javascript:;" class="search"></a>
    </div>
    <ul class="list" id="list"></ul>        
</div> 
<script>
function loadScript(url){
    loadScript.mark = 'load';
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = url;
    document.body.appendChild(script);
}
function callback(data){
    if(data){
        var arr = data.s;
        var html = '';
        for(var i = 0,len = arr.length; i < len; i++){
            html+= "<li class='in'><a href='https://www.baidu.com/s?wd="+ arr[i]+"' target='_blank' style='display:block'>" + arr[i]+ "</a></li>"
        }
        list.innerHTML = html;        
    }
}
search.onkeyup = function(e){
    e = e || event;
    if(e.keyCode == '13'){
       window.open('https://www.baidu.com/s?wd=' + this.value);
    }
    if(this.value){
        if(search.data != this.value){
            btn.setAttribute('href','https://www.baidu.com/s?wd=' + this.value);
            var that = this;
            loadScript("https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + that.value + "&&cb=callback");
        }
    }else{
        list.innerHTML = '';
    }
    search.data = this.value;
}
search.onclick = function(e){
    e = e || event;
    list.style.display = 'block';
    if(e.stopPropagation){
        e.stopPropagation();
    }else{
        e.cancelBubble = true;
    }
}
document.onclick = function(){
     list.style.display = 'none';
}
</script>

jquery

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    body {
        margin: 0;
    }

    ul {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    a {
        color: inherit;
        text-decoration: none;
    }

    input {
        padding: 0;
        border: 0;
    }

    .box {
        width: 340px;
        height: 38px;
        border: 2px solid gray;
    }

    .con {
        overflow: hidden;
    }

    .input {
        float: left;
        width: 300px;
        height: 38px;
    }

    .search {
        width: 38px;
        height: 38px;
        float: right;
        background: url('http://sandbox.runjs.cn/uploads/rs/26/ddzmgynp/search.png') 0 -38px;
    }

    .list {
        position: absolute;
        width: 298px;
        border: 1px solid #e6e8e9;
        overflow: hidden;
    }

    .in {
        line-height: 30px;
        border-bottom: 1px solid lightblue;
        cursor: pointer;
        text-indent: 1em;
    }

    .list .in:last-child {
        margin-bottom: -1px;
    }

    .in:hover {
        background-color: #f9f9f9;
    }
    </style>
</head>

<body>
    <div class="box" id="box">
        <div class="con">
            <input class="input" id="search" data-a="aa">
            <a target="_blank" id="btn" href="javascript:;" class="search"></a>
        </div>
        <ul class="list" id="list"></ul>
    </div>
</body>

</html>
<script type="text/javascript" src="../jq/js/jquery-1.11.3.js"></script>
<script type="text/javascript">
$('#search').bind('keyup', function(e) {
    var that = this;
    if (e.keyCode == 13) {
        window.open('https://www.baidu.com/s?wd=' + $(this).val());
        //跳转到百度
    }
    if ($(this).val()) {
        if ($(this).data('a') != $(this).val()) { //不允许搜索aa
            $('#btn').attr('href', 'https://www.baidu.com/s?wd=' + $(this).val());
        }
        console.log('sss');
        $.ajax({
            url: "https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + $(this).val(),
            type: "get",
            //jsonp只能用get
            async: true,
            dataType: "jsonp",
            jsonp:'cb',
            //在一个jsonp请求中重写回调函数的名字。这个值用来替代在"callback=?"这种GET或POST请求中URL参数里的"callback"部分,比如{jsonp:'onJsonPLoad'}会导致将"onJsonPLoad=?"传给服务器

            jsonpCallback:"callback",
            //"https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=" + that.value + "&&cb=callback"
            //为jsonp请求指定一个回调函数名。这个值将用来取代jQuery自动生成的随机函数名。这主要用来让jQuery生成度独特的函数名,这样管理请求更容易,也能方便地提供回调函数和错误处理。你也可以在想让浏览器缓存GET请求的时候,指定这个回调函数名

            success: function(data){
                var arr = data.s;
                var html = '';
                $.each(arr,function(k,v){
                    html+= "<li class='in'><a href='https://www.baidu.com/s?wd="+ v+"' target='_blank' style='display:block'>" + v+ "</a></li>"
                })
                $('.list').html(html);
            }
        });
    }else{
         $('.list').html('');
    }


});
$(document).click(function(){
     $('.list').html('');
})
</script>
Ajax+JSON 搜索框自动完成提示功能 NULL 博文链接:https://chaoyi.iteye.com/blog/2162368 立即下载

相关推荐

PHP jQuery json搜索框智能标签提示实例

PHP jQuery json搜索框输入提示特效,运用了JSON技术实现的ajax搜索提示。 免积分下载:http://www.srcfans.com/code/12100.shtml 当用户在搜索框输入内容时,可显示出可能的内容列表,会智能匹配搜索项,用户可通过鼠标选择这些匹配项,免去用户操作的麻烦。另外本效果也可用户标签输入提示效果,匹配项会智能填充背景,并添加删除功能,在一些大网站,经常见到这种效果,希望本源码会对你有所帮助。

JSONP跨域详解 + 模拟百度搜索,web后端开发框架

本人分享一下这次字节跳动、美团、头条等大厂的面试真题涉及到的知识点,以及我个人的学习方法、学习路线等,当然也整理了一些学习文档资料出来是附赠给大家的。知识点涉及比较全面,包括但不限于前端基础,HTML,CSS,JavaScript,Vue,ES6,HTTP,浏览器,算法等等详细大厂面试题答案、学习笔记、学习视频等资料领取,点击资料领取直通车免费领取!题涉及到的知识点,以及我个人的学习方法、学习路线等,当然也整理了一些学习文档资料出来是附赠给大家的。知识点涉及比较全面,包括但不限于。

qiqiyuer的博客 995

百度搜索框智能提示案例jsonp

先给大家展示下效果图: 下面一段代码给大家分享了百度搜索框智能提示案例jsonp的知识,具体代码如下所示: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>百度下拉_sug-jquery</title> [removed][removed] <style> #sug{ position: absolute; left: 50%; margin-left: -150px; margin-top: 200px; width: 300px; background

通过 jsonp 跨域获取百度搜索内容/(函数的防抖)

利用 input输入框 获取百度输入框的内容 1 找到百度搜索数据的请求网址 图6 就是数据请求的url地址 我们需要做成这种效果 2 原码演示 * { margin: 0; padding: 0; } ul, ol, li { list-style: none; } .search { ...

m0_61382303的博客 1008

Prompt Airlines CTF通关实战:从提示词注入到多模态攻击的AI安全攻防演练

提示词注入(Prompt Injection)是当前大语言模型(LLM)应用面临的核心安全威胁之一,其原理在于攻击者通过精心构造的用户输入,覆盖或绕过系统预设的指令,从而操控模型行为。这种攻击手法的技术价值在于揭示了AI系统在理解与执行指令时存在的逻辑边界模糊性,可能导致数据泄露、越权访问等严重风险。在应用场景上,从基础的客服对话到结合视觉识别的多模态系统,都可能成为攻击面。本文以一场名为“Prompt Airlines CTF”的实战挑战为例,深入剖析了包括指令遗忘、上下文注入、工具调用滥用及多模态提示注

aodan5477的博客 515

VS2019手动添加bits/stdc++.h全指南(附解决‘无法打开源文件‘错误)

本文详细介绍了在Visual Studio 2019中手动配置C++万能头文件bits/stdc++.h的完整方法,解决常见的'无法打开源文件'错误。通过分析GCC与MSVC编译器生态差异,提供了纯手动创建和MinGW移植两种可靠方案,并给出详细的步骤、常见错误排查及最佳实践建议,帮助开发者高效配置竞赛开发环境。

weixin_29011395的博客 545

JSONP跨域+百度搜索案例实现

由于浏览器安全限制,不同的根域名、二级域名、不同端口之间的数据不可以直接跨域,所以用JSONP(JSON with Padding),其是JSON的一种补充使用方式,不是官方协议,而是利用 Script 标签请求资源可以跨域的特点来解决跨域问题,是一种变通的解决方案。

qq_56715703的博客 861

从ENVI SARscape到SNAP:手把手教你迁移哨兵1 GRD数据预处理流程(含避坑指南)

本文详细介绍了从ENVI SARscape迁移到SNAP处理哨兵1 GRD数据的全流程,包括工具哲学差异、数据准备注意事项、核心处理流程等效实现及地形校正技巧。特别针对雷达数据预处理中的常见陷阱提供避坑指南,帮助用户高效完成工具迁移并确保结果质量。

weixin_28677005的博客 485

【实战】JSONP跨域之『百度联想词搜索』

一、JSONP跨域 (1)说明 JSONP-JSON with Padding: 跨域获取JSON数据的一种非官方的使用模式 JSON和JSONP不是一个类型 JSON是数据交换格式 JSONP是一种跨域获取JSON数据的交互技术(非常正式的协议) JSONP抓取的资源并不直接是JSON数据,而是带有JSON数据参数的函数执行 JSON返回的:{“name”:“cc”} JSONP返回的:callback({‘name’:‘cc’}) (2)前奏 同源策略到底给谁走了后门? img的src lin

小管打天下的博客 476

Quartus ||———基于Verilog HDL的数字秒表设计实验

Quartus ||———基于Verilog HDL的数字秒表设计实验一、实验目的二、实验步骤(一)新建工程(二)添加设计文件(三)综合分析与功能仿真1、综合分析2、功能仿真 一、实验目的 用Verilog HDL设计一个数字跑表,所需引脚和功能如下: 二、实验步骤 (一)新建工程 在创建好工程名称后,选定芯片类型 (二)添加设计文件 新建Verilog文件,键入代码如下 module n_clk_top( input clk, input rese

TBMmagic的博客 5525

手把手教你用Copilot插件在Obsidian里免费接入DeepSeek-R1(附硅基流动API密钥获取)

本文详细介绍了如何通过Copilot插件在Obsidian中免费接入DeepSeek-R1模型,实现智能知识管理。从硅基流动API密钥获取到插件配置,再到高级功能调优和实战应用技巧,手把手教你打造AI驱动的个人知识库。

weixin_33686714的博客 2792

关于jsonp的理解。利用 百度“联想搜索”接口

关于jsonp的理解。利用 百度“联想搜索”接口

慢才后生 1165

GradNorm:Gradient Normalization for Adaptive Loss Balancing in Deep Multitask Networks,梯度归一化

文章目录引言gradnorm   gradnorm论文地址:https://arxiv.org/abs/1711.02257   gradnorm是一种优化方法,在多任务学习(Multi-Task Learning)中,解决 1. 不同任务loss梯度的量级(magnitude)不同,造成有的task在梯度反向传播中占主导地位,模型过分学习该任务而忽视其它任务;2. 不同任务收敛速度不一致;这两个...

Leon_winter的博客 2万+

Jsonp原理+百度搜索框

Jsonp原理+百度搜索框 由于浏览器同源策略的限制,不同源的客户端脚本在没明确授权的情况下,不能读写对方的资源。 但是在实际项目中经常需要跨域进行访问,Jsonp就是一种很好的解决跨域问题的方法。 Jsonp原理 1.Web页面上用script标签引入JS文件时则不受是否跨域的影响(不仅如此,我们还发现凡是拥有“src”这个属性的标签都拥有跨域的能力,比如script、img、iframe) 2...

zzzzzzz823的博客 388

基于反事实的因果推理Causal inference based on counterfactuals--一万六千字文献详细解读(因果关系的推理应用)【全文总结】

基于反事实的因果推理Causal inference based on counterfactuals--一万六千字文献详细解读(因果关系的推理应用)【全文总结】---来自一位即将入学的准研一,也希望这篇文章能够激励自己不断走下去!!

qq_46044325的博客 4442

leetcode134 加油站

题目如下 在一条环路上有 N 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。 如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1。 说明: 如果题目有解,该答案即为唯一答案。 输入数组均为非空数组,且长度相同。 输...

ayang818 's blog 233

JSONP跨域实现百度搜索框联想词

所谓同源 即满足协议(http/https),域名(wwww.baidu.com),端口(80)都相同的两个页面,同源策略就是当两个页面不满足同源这个条件的话, 1,不能获取不同源的cookie,LocalStorage 和 indexDB 2,不能获取非同源的DOM 3,不能发送非同源的ajax请求。 简单的来说就是不能请求对方的资源。 所以我们要想使用百度的接口,实现效果,就必须进行跨域操作。...

qq_42040061的博客 490

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

Jsonp --- 利用Jsonp做百度搜索框

解决浏览器跨域问题的几种方法 flash 服务器代理中转 Jsonp document.domain(针对基础域名相同的情况) 这篇博客主要介绍JsonpJosnp JSONP(JSON with Padding)是JSON的一种“使用模式”,可用于解决主流浏览器的跨域数据访问的问题。由于同源策略,一般来说位于 server1.example.com 的网页无法与不是 server1.exa

翾的博客 1458

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

jsonp模拟百度搜索框

代码如下: Title *{ margin:0; padding:0; font-family:"Microsoft yahei",serif;} li{ list-style-type: none;} #box{

MOONCOM的博客 929

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

百度搜索框案例,jsonp实现搜索功能

想要实现该功能得先有一个接口–>百度搜索框数据接口 API地址后面进行拼接 wd=后面跟的就是要搜索的关键词,因此我们只需要将input框中的值传到wd=后面,然后通过jsonp跨域实现搜索功能 jsonp跨域详解 附上全部代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" co.

MyBlog 603

Ajax跨域:Jsonp实例--百度搜索框下拉提示

Ajax跨域:Jsonp实例--百度搜索框下拉提示 一、总结 一句话总结:a、找好接口;b、用script标签的src引入文件(json数据);c、定义及实现上一步引入文件中的函数 1、如何找到一个网站的请求的接口? google浏览器->F12->Network 2、Jsonp是什么? Jsonp(JSON with Padding) 是 json 的一种"使...

weixin_34329187的博客 118

javascript搜索框联想搜索_模拟百度搜索框自动联想功能,原生js+jsonp轻松搞定

链接下面是我闲暇时总结的JS、CSS、算法总结,欢迎大家点赞、star~~有趣实用的CSS效果前端博客 传送门LeetCode个人题解 传送门讲解如何利用百度接口仿写一个搜索联想词功能效果图 HTML部分ul>div>CSS样式部分* {padding: 0;margin: 0;}.wrapper {position: absolute;margin-left: -260px;left...

weixin_42348394的博客 518

【JSONP 笔记】模拟百度的下拉搜索框

JSONP原理 1、Web页面上用 <script> 引入 js 文件时则不受是否跨域的影响 (不仅如此,我们还发现凡是拥有"src"这个属性的标签都拥有跨域的能力,比如 <script>、<img>、<iframe>) 2、于是我们把数据放到服务器上,并且数据为 json 形式(因为 js 可以轻松处理 json 数据) 3、因为我们无法监控通过 <script> 的 src 属性是否把数据获取完成,所以我们需要做一个处理 4、实现定义好处理跨域

JT61100的博客 262

使用jsonp跨域调用百度js实现搜索框智能提示,并实现鼠标和键盘对弹出框里候选词的操作【附源码和在线测试地址】

使用jsonp跨域调用百度js实现搜索框智能提示,并实现鼠标和键盘对弹出框里候选词的操作【附源码和在线测试地址】

ugfdfgg的博客 325
上一篇: window.postMessage
下一篇: float,clear
han_hanker
博客等级 码龄13年 35粉丝 106原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值