Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.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
jQuery:从genderAPI获取结果_Jquery_Api - Fatal编程技术网

jQuery:从genderAPI获取结果

jQuery:从genderAPI获取结果,jquery,api,Jquery,Api,我正在为我的项目使用withjQuery。 我试图得到#name的性别结果,但似乎我的代码根本无法识别它(没有发出警报)。有人能告诉我为什么吗 他们提供的jQuery插件示例如下: $('input#firstname').genderApi({key: genderApiClientKey}).on('gender-found', function(e, result) { if (result.accuracy >= 60) { alert('Gender fou

我正在为我的项目使用with
jQuery

我试图得到
#name
的性别结果,但似乎我的代码根本无法识别它(没有发出
警报
)。有人能告诉我为什么吗

他们提供的
jQuery插件
示例如下:

$('input#firstname').genderApi({key: genderApiClientKey}).on('gender-found', function(e, result) {

  if (result.accuracy >= 60) {    
    alert('Gender found: ' + result.gender);  
  }

});
下面是我的尝试,您可以找到完整的代码:

HTML:


您正在尝试为下面的文本字段执行genderAPI吗

<input type="text" placeholder="Please enter your name here" id="term" />
var apiUrl = "https://sheetsu.com/apis/f924526c"; // this is another API I created on Google Spreadsheet

$.getJSON(apiUrl, function (json) {

    console.log(JSON.stringify(json));
    var item = json.result.find(function (e) {

        return e.name == content;

    }) || json.result[0];
    console.log("PRINT ID: " + item.id);


    var name = item.name || content;
    var $nameText = $("#nameText"),
        str = name;
    html = $.parseHTML(str),
        nodeNames = [];
    $nameText.append(html);
    console.log("Name: " + name);

    // genderAPI here to get gender result
    $('name').genderApi({
        key: "oyxLJkutVSYXWNVzGP"
    }).on('gender-found', function (e, result) {
        if (result.accuracy >= 60) {
            alert('Gender found: ' + result.gender);
        }
    });
});
<input type="text" placeholder="Please enter your name here" id="term" />
   $('input#term').genderApi({
        key: "oyxLJkutVSYXWNVzGP"
    }).on('gender-found', function (e, result) {
        if (result.accuracy >= 60) {
            alert('Gender found: ' + result.gender);
        }
    });