comment jquery script
http://viima.github.io/jquery-comments/#link-3-4
Ik heb hier een test array van comments
Dit probeer ik te krijgen met een ajax call vanuit mijn database:
in blog_comments.php geeft ik dit terug:
Ik krijg een error:
VM244743:296 Uncaught TypeError: commentsArray.map is not a function
at commentsFetched (eval at <anonymous> (jquery-1.12.4.min.js:2), <anonymous>:296:51)
at Object.success (indonesia:8082)
at i (jquery-1.12.4.min.js:2)
at Object.fireWith [as resolveWith] (jquery-1.12.4.min.js:2)
at y (jquery-1.12.4.min.js:4)
at XMLHttpRequest.c (jquery-1.12.4.min.js:4)
Hoe krijg ik de array exact zo terug?
Ik gebruik dit script: Ik heb hier een test array van comments
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var commentsArray = [
{
"id": 1,
"parent": null,
"created": "2015-01-01",
"modified": "2015-01-01",
"content": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed posuere interdum sem. Quisque ligula eros ullamcorper quis, lacinia quis facilisis sed sapien. Mauris varius diam vitae arcu.",
"pings": [],
"creator": 6,
"fullname": "Simon Powell",
"profile_picture_url": "https://app.viima.com/static/media/user_profiles/user-icon.png",
"created_by_admin": false,
"created_by_current_user": false,
"upvote_count": 0,
"user_has_upvoted": false,
"is_new": false
},
{
"id": 2,
"parent": null,
"created": "2015-01-02",
"modified": "2015-01-02",
"content": "Sed posuere interdum sem. Quisque ligula eros ullamcorper quis, lacinia quis facilisis sed sapien. Mauris varius diam vitae arcu.",
"pings": [],
"creator": 5,
"fullname": "Administrator",
"profile_picture_url": "https://app.viima.com/static/media/user_profiles/admin-user-icon.png",
"created_by_admin": true,
"created_by_current_user": false,
"upvote_count": 2,
"user_has_upvoted": false,
"is_new": false
}
{
"id": 1,
"parent": null,
"created": "2015-01-01",
"modified": "2015-01-01",
"content": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed posuere interdum sem. Quisque ligula eros ullamcorper quis, lacinia quis facilisis sed sapien. Mauris varius diam vitae arcu.",
"pings": [],
"creator": 6,
"fullname": "Simon Powell",
"profile_picture_url": "https://app.viima.com/static/media/user_profiles/user-icon.png",
"created_by_admin": false,
"created_by_current_user": false,
"upvote_count": 0,
"user_has_upvoted": false,
"is_new": false
},
{
"id": 2,
"parent": null,
"created": "2015-01-02",
"modified": "2015-01-02",
"content": "Sed posuere interdum sem. Quisque ligula eros ullamcorper quis, lacinia quis facilisis sed sapien. Mauris varius diam vitae arcu.",
"pings": [],
"creator": 5,
"fullname": "Administrator",
"profile_picture_url": "https://app.viima.com/static/media/user_profiles/admin-user-icon.png",
"created_by_admin": true,
"created_by_current_user": false,
"upvote_count": 2,
"user_has_upvoted": false,
"is_new": false
}
Dit probeer ik te krijgen met een ajax call vanuit mijn database:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
getComments: function(success, error) {
$.ajax({
type: 'get',
dataType : 'json',
url: '<?=HTML_ROOT?>inc/blog_comment.php?country=<?=$folder2?>',
success: function(commentsArray) {
console.log(commentsArray);
success(commentsArray)
},
error: error
});
},
$.ajax({
type: 'get',
dataType : 'json',
url: '<?=HTML_ROOT?>inc/blog_comment.php?country=<?=$folder2?>',
success: function(commentsArray) {
console.log(commentsArray);
success(commentsArray)
},
error: error
});
},
in blog_comments.php geeft ik dit terug:
Code (php)
1
echo json_encode(array('id' => 3 , 'parent' => null, 'created' => '2015-01-03' , 'modified' => '2015-01-03', 'content' => '@Hank Smith sed posuere interdum sem.\nQuisque ligula eros ullamcorper https://www.google.com/ q' , 'fullname' => 'test' , 'profile_picture_url' => 'https://app.viima.com/static/media/user_profiles/user-icon.png'));
Ik krijg een error:
VM244743:296 Uncaught TypeError: commentsArray.map is not a function
at commentsFetched (eval at <anonymous> (jquery-1.12.4.min.js:2), <anonymous>:296:51)
at Object.success (indonesia:8082)
at i (jquery-1.12.4.min.js:2)
at Object.fireWith [as resolveWith] (jquery-1.12.4.min.js:2)
at y (jquery-1.12.4.min.js:4)
at XMLHttpRequest.c (jquery-1.12.4.min.js:4)
Hoe krijg ik de array exact zo terug?
Gewijzigd op 05/05/2017 17:17:20 door Thomas van den Heuvel