Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Google Sheet API进行实时Json数据搜索Ajax jQuery_Javascript_Jquery_Json_Google Sheets_Google Sheets Api - Fatal编程技术网

Javascript 使用Google Sheet API进行实时Json数据搜索Ajax jQuery

Javascript 使用Google Sheet API进行实时Json数据搜索Ajax jQuery,javascript,jquery,json,google-sheets,google-sheets-api,Javascript,Jquery,Json,Google Sheets,Google Sheets Api,我正在寻找一个实时数据搜索与电子表格JSON 事实上,我面临的主要问题是获取数据 控制台日志显示“uncaughtreferenceerror:i未定义”我正在使用PHP扩展 $(文档).ready(函数(){ $(“#搜索”).keyup(函数(事件){ //$.ajaxSetup({cache:false}); $('#result').html(''); var searchField=$('#search').val(); var表达式=新的RegExp(searchField,“

我正在寻找一个实时数据搜索与电子表格JSON

事实上,我面临的主要问题是获取数据

控制台日志显示“uncaughtreferenceerror:i未定义”我正在使用PHP扩展

$(文档).ready(函数(){
$(“#搜索”).keyup(函数(事件){
//$.ajaxSetup({cache:false});
$('#result').html('');
var searchField=$('#search').val();
var表达式=新的RegExp(searchField,“i”);
jsonData=”https://spreadsheets.google.com/feeds/list/1l7VfPOI3TYtPuBZlZ-JMMiZW1OK6rzIBt8RFd6KmwbA/od6/public/values?alt=json";
$.getJSON(jsonData,函数(数据){
name=data.feed.entry[i]['gsx$name']['$t'];
img=data.feed.entry[i]['gsx$img']['$t'];
price=data.feed.entry[i]['gsx$price']['$t'];
$。每个(数据、函数(键、值){
if(value.name.search(表达式)!=-1 | | value.location.search(表达式)!=-1){
$(“#result”).append(“
  • ”+value.name+“|”+value.price+”
  • ”); } }); }); }); });
    .bs示例{
    利润率:20px;
    }
    
    


    您需要在循环中移动行,并从每个行的索引中分配i

    但是,这有很大的改进-我先进行筛选,然后分配LIs:

    我删除了位置搜索,因为我在数据中没有看到位置

    $(文档).ready(函数(){
    $(“#搜索”).keyup(函数(事件){
    //$.ajaxSetup({cache:false});
    $('#result').html('');
    var searchField=$('#search').val();
    var表达式=新的RegExp(searchField,“i”);
    jsonData=”https://spreadsheets.google.com/feeds/list/1l7VfPOI3TYtPuBZlZ-JMMiZW1OK6rzIBt8RFd6KmwbA/od6/public/values?alt=json";
    $.getJSON(jsonData,函数(数据){
    consthtml=data.feed.entry.filter(entry=>{
    返回条目['gsx$name']['$t']。搜索(表达式)!=-1
    })
    .map(条目=>{
    const name=条目['gsx$name']['$t'],
    img=条目['gsx$img']['$t'],
    价格=分录['gsx$price']['$t'];
    console.log(名称)
    返回`
  • ${name}|${price}
  • ` }).加入(“”); $(“#结果”).html(html); }); }); });
    .bs示例{
    利润率:20px;
    }
    
    

           name = data.feed.entry[i]['gsx$name']['$t'];
           img = data.feed.entry[i]['gsx$img']['$t'];
           price = data.feed.entry[i]['gsx$price']['$t'];