解析查询包括不工作

时间:2015-12-31 10:11:35

标签: javascript parse-platform

var query = new Parse.Query("Product");
query.descending("createdAt");
query.equalTo("objectId", "<?php print $objectId;?>");
query.include("Product.user");
query.find({
success: function(results) {
    var seller_id = " ";
    $("#fetching-item").fadeOut("slow");

    for (var i = 0; i < results.length; i++) {
        var object = results[i];
        var pic = object.get("product_image");
        var pics = object.get("item_images");
        var the_img = pic.url();
        var user = object.get("user");
        var seller = user.get("username");
        var seller_id = user.id;

        if (object.get('product_category') != 'Accommodation') {
            $('#house_data').hide();
        }

        $('#productDetail').append('<img src=' + the_img + ' class="img-detail">' + '<div class="content item-content"><h4 class="list-group-item-heading">' + object.get('product_title') + ' ' + object.createdAt.toLocaleString() + ' ' + '<span class="lead text text-info">, Ksh. ' + object.get('product_price') + '</span></h4>' + '<p class="list-group-item-text">' + object.get('product_description') + '</p>' + '<p class="list-group-item-text"><span class="mdi-maps-place text text-danger"></span>' + object.get("product_seller_location") + '</p>' + '</div>');

        $('#house_data').append('<div><p class="list-group-item-text">Type:     ' + object.get('house_type') + '</p>' + '<p class="list-group-item-text">Design: ' + object.get('house_design') + '</p>' + '<p class="list-group-item-text">Owner: ' + object.get('owner_name') + '</p>' + '<p class="list-group-item-text">Rooms: ' + object.get('number_of_rooms_available') + '</p>' + '</div>');

        $("#seller").html("<span class='text text-info'><span class='mdi-action-account-circle'></span>" + "<a href='http://swap254.com/user/profiles/" + seller + "'>" + seller + "</a></span>");

        $("#seller_info").append('<p><a href="tel:' + user.get('user_phone_number') + '"><span class="mdi-communication-call"></span>' + user.get('user_phone_number') + '</a></p>' + '<p><span class="mdi-action-schedule text text-info"></span>Member Since' + '  ' + /*user.createdAt.toLocaleString()+*/ '</p>');

        /*if seller = currentUser*/
        /*current_user_id = Parse.User.current().id;
        if(seller_id == current_user_id){
             $("#edit-prompt").html("Edit this item");
        }*/
    }
},
error: function(error) {
    setTimeout(function() {
        toastr.error("Sorry, there's been a connection error, please check your internet connection");
    }, 1500);
    $("#fetching-item").fadeOut("slow");
  }
});

我正在尝试查询具有指针'user'的产品类到_User类。然而,当我在console.log时,我遇到了用户未定义的问题。 可能有我遗失的东西吗?

0 个答案:

没有答案