Hello, I have a ajax in my localhost and is working good, but when I put it in the dopplet no is working. Any block? I must config anything more?
My ajax:
$.ajax({
type: "post",
url: url,
data: {"_token": "{{ csrf_token() }}",
year: year, index: index
},
success: function(data) {
$.each(data,function(key,value){
var oBox=$('<div>').addClass('box').appendTo($('#gallery'));
var oPic=$('<div>').addClass('pic').appendTo(oBox);
$('<img>').attr('src', $(value).attr('src')).appendTo(oPic);
});
My Laravel controller:
public function gallery(Request $request)
{
$json = Photo::where('year', '=', $request->year)->skip(20 * $request->index)->take(20)->get();
if (!$json->isEmpty()) {
foreach ($json as $data)
{
$elements[] = ['src' => '../img/gallery/'.$data->year.'/'.$data->filename.'.'.$data->extension, 'download' => '../img/gallery/'.$data->year.'/download/'.$data->filename.'.'.$data->extension];
}
$json = response()->json($elements);
}
return $json;
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there @alquilariumdev,
The code that you’ve shared looks good. I would recommend checking your web console for any errors, to do that just right click on your website, then clock on ‘Inspect element’, after that go to the console tab. After that try to trigger the AJAX request and see if any errors pop up in the console.
Feel free to share the errors here so I could try to advise you further.
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.