JQuery - 未捕获的TypeError:无法读取未定义的属性“结果”

时间:2018-05-09 08:34:28

标签: javascript php html

我已经像这样创建了一个form.html

<form class="smallForm" id="form" onsubmit="event.returnValue = false; return false">
 Name: <input type = "text" name = "domain" />
      <select name="domain_ext" class="inputAuto">
        <option value=".com">.com</option>
      </select>
     <input type = "submit" />
</form>

在test.php中,我尝试创建一个curl get方法

error_reporting(E_ERROR );
$a = $_POST["domain"];
$b = $_POST["domain_ext"];

function httpGet($url)
{
    $ch = curl_init();  

    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//  curl_setopt($ch,CURLOPT_HEADER, false); 

    $output=curl_exec($ch);

    curl_close($ch);
    return $output;
}
echo httpGet("https://xxxx.jsp?domain=$a$b");

要让结果直接显示在表格表格下,我创建一个代码为

的js文件
 function domain_ajax_click_ffactory(mode) {
  'use strict';
  var form_domain = 'domain';
  var form_domain_ext = 'domain_ext';

  return function () {
    domain_loading(mode);

    var domain =
      $('#domain_' + mode + '_form input[name=' + form_domain + ']').val();
    var domain_ext =
      $('#domain_' + mode + '_form select[name=' + form_domain_ext + ']').val();

       var enc_domain = encodeURIComponent(domain);
        var enc_domain_ext = encodeURIComponent(domain_ext);

        if (!domain || !domain_ext) {
          domain_loaded(mode);
        } else {
          $.ajax({
            url: '//xxxx.com/test.php',
            type: 'get',
            dataType: 'json',
            data:
              'domain=' + enc_domain +
              '&domain_ext=' + enc_domain_ext +
              '&form=domain_' + mode + '_form'
          }).always(domain_ajax_always_ffactory(mode, enc_domain, enc_domain_ext));
        }
      };
    }


    function domain_ajax_always_ffactory(mode, enc_domain, enc_domain_ext) {
  'use strict';
  var f;

  switch (mode) {
  case 'whois':
    f = function(data, status, jqxhr) {
      $('#domain_whois_loaded').text(data.domain_whois.result);
      domain_loaded(mode);
    };
    break;
  }

  return f;
}

但是,当我输入文本字段并提交表单时,没有结果,我在控制台日志中看到错误“Uncaught TypeError:无法读取未定义的属性'结果'”。我真的需要有人帮忙。提前谢谢。

0 个答案:

没有答案