Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.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 无法读取属性';第'行;未定义的 //在将此页面呈现到用户屏幕之前,“pagebeforecreate”中的任何内容都将执行 $(文档)。在(“pagebeforecreate”上,函数(){ printheader();//在用户看到其页面之前先打印标题 }); $(文档).ready(函数(){ searchfriend(); 函数searchfriend(){ var url=serverURL()+“/getcategories.php”; $.ajax({ url:url, 键入:“GET”, 数据类型:“json”, contentType:“应用程序/json;字符集=utf-8”, 成功:功能(arr){ _getCategoryResult(arr); }, 错误:函数(){ validationMsg(); } }); } 函数_getCategoryResult(arr){ var t;//声明变量t //循环获取getcategories.php找到的结果数 对于(变量i=0;i_Javascript_Php_Visual Studio - Fatal编程技术网

Javascript 无法读取属性';第'行;未定义的 //在将此页面呈现到用户屏幕之前,“pagebeforecreate”中的任何内容都将执行 $(文档)。在(“pagebeforecreate”上,函数(){ printheader();//在用户看到其页面之前先打印标题 }); $(文档).ready(函数(){ searchfriend(); 函数searchfriend(){ var url=serverURL()+“/getcategories.php”; $.ajax({ url:url, 键入:“GET”, 数据类型:“json”, contentType:“应用程序/json;字符集=utf-8”, 成功:功能(arr){ _getCategoryResult(arr); }, 错误:函数(){ validationMsg(); } }); } 函数_getCategoryResult(arr){ var t;//声明变量t //循环获取getcategories.php找到的结果数 对于(变量i=0;i

Javascript 无法读取属性';第'行;未定义的 //在将此页面呈现到用户屏幕之前,“pagebeforecreate”中的任何内容都将执行 $(文档)。在(“pagebeforecreate”上,函数(){ printheader();//在用户看到其页面之前先打印标题 }); $(文档).ready(函数(){ searchfriend(); 函数searchfriend(){ var url=serverURL()+“/getcategories.php”; $.ajax({ url:url, 键入:“GET”, 数据类型:“json”, contentType:“应用程序/json;字符集=utf-8”, 成功:功能(arr){ _getCategoryResult(arr); }, 错误:函数(){ validationMsg(); } }); } 函数_getCategoryResult(arr){ var t;//声明变量t //循环获取getcategories.php找到的结果数 对于(变量i=0;i,javascript,php,visual-studio,Javascript,Php,Visual Studio,第33行有一个错误,说明: “未捕获的TypeError:无法读取未定义的属性“行” 然而,我似乎不知道错误是从哪里来的 我能解决这个问题吗 变量t不是具有名为row的属性的对象。 尝试使用var t={row:[]} 编辑:我道歉。我把加法和推法搞混了 因此,您需要一个名为add方法的对象,并将该对象分配给t您看起来像在使用第三方jQuery插件。 遵循数据表的用法 vart//声明变量t 应该是 var t=$(“#categoryresult”).DataTable(); 在某个地方,您

第33行有一个错误,说明:

“未捕获的TypeError:无法读取未定义的属性“行”

然而,我似乎不知道错误是从哪里来的


我能解决这个问题吗

变量
t
不是具有名为
row
的属性的对象。 尝试使用
var t={row:[]}

编辑:我道歉。我把加法和推法搞混了


因此,您需要一个名为
add
方法的对象,并将该对象分配给
t
您看起来像在使用第三方jQuery插件。 遵循数据表的用法

vart//声明变量t
应该是

var t=$(“#categoryresult”).DataTable();

在某个地方,您正在访问
未定义的.row
,或者更可能是未定义的变量。因此,属性行未定义。这有用吗?你的
PHP
代码在哪里?不应该是什么对象?从您的代码中,它只是一个未定义的变量,因此您将得到错误。也发布剩余的代码。。HTML+PHPIt将导致错误
add不是函数
,因为
add
不是数组。原型函数。。。
//anything inside 'pagebeforecreate' will execute just before this page is rendered to the user's screen 

$(document).on("pagebeforecreate", function () {
    printheader(); //print the header first before the user sees his page
});

$(document).ready(function () {
    searchfriend();

    function searchfriend() {
    var url = serverURL() + "/getcategories.php";

    $.ajax({
        url: url,
        type: 'GET',
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        success: function (arr) {
            _getCategoryResult(arr);
        },
        error: function () {
            validationMsg();
        }
    });
}

function _getCategoryResult(arr) {

    var t; //declare variable t
    //loop for the number of results found by getcategories.php
    for (var i = 0; i < arr.length; i++) {
        //add a new row
        t.row.add([ //error
            "<a href='#' class='ui-btn' id='btn" + arr[i].categoryID + "'>Category</a>" //add a new [Category] button
        ]).draw(false);

        //We drew a [View] button. now bind it to some actions
        $("#btn" + arr[i].categoryID).bind("click", { id: arr[i].categoryID }, function (event) {
            var data = event.data;
            showcategory(data.id); //when the user clicks on the [View] button, execute showcategory()
        });

    }
    $("#categoryresult").show(); //show the results in the table searchresult
}
function showcategory(categoryID) {
    //alert(categoryID);
    window.location = "showuser.html?userid=" + userid;

}
});