Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database issue #166

Closed
CHEMAX3X opened this issue Jan 25, 2018 · 6 comments
Closed

Database issue #166

CHEMAX3X opened this issue Jan 25, 2018 · 6 comments
Labels

Comments

@CHEMAX3X
Copy link

Hello, im using your plugin but i have a problem, i call my images from the database and pass them to the plugin but it doesnt read them, however if i copy what is inside the array of images into the plugin it works. Here is my code :

JS
$.get('ajax/slides.php', function(data) {
$('#slideMain').vegas({
slides: [ data ]
});
});
////////////////////////////////////////////
AJAX file
$slide = new slideManager();
$slide ->showSlideController();

echo $slide;
//////////////////////////////////////////
PHP
public function showSlideController(){
$answer = slideModel::showSlideModel("slides");
foreach($answer as $row => $item){
echo '{ src: "'.$item['path'].'" },'; // Even if i print it like this doesnt work
}
}
////////////////////////////////////////
Again i got all my images but they are not displayed in the plugin,

Any help will be more than welcome, thanks in advance =D

@jaysalvat
Copy link
Owner

Hello.
You are not generating standard JSON.

1/ PHP must generate a standard JSON array with src inside
2/ JS must load JSON and add it to Vegas properly

Hope it helps.

@CHEMAX3X
Copy link
Author

CHEMAX3X commented Jan 25, 2018

Hello, thanks for the reply, look, the problem is that i dont know how to add them to Vegas properly, i have my JSON array and i got the images, for example, if i do this to test the JSON :

$('#slideMain').append('<img src="'+slides["path"]+'">');

i see all the images, however if i do the same in Vegas, it only displays the first image, and if i left it like:

{src: slides}, it only shows me an string with console.log.

Here is the code if it helps :

foreach($answer as $row => $item){
$slides[] = array('path'=>substr($item["path"], 6));
}
$jsonSlides = json_encode($slides);
echo $jsonSlides;

And in JS

$.getJSON('ajax/Slides.php', function(slide) {
$.each(slide, function(i,newslides){
$('#slideMain').vegas({
slides: [
{src: newslides["path"]}
]
});
})
});

Thanks again for all your help =D

@jaysalvat
Copy link
Owner

Your keys and json structure seems wrong.
why 'path' ?

@CHEMAX3X
Copy link
Author

CHEMAX3X commented Jan 26, 2018 via email

@jaysalvat
Copy link
Owner

Give Vegas the JSON it needs and it will work :)
It seems your JSON is not correct.

@CHEMAX3X
Copy link
Author

Ok, i will see what can i do, thanks again for all your help =)

Best regards =D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants