Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Cronix's avatar

Do you get any errors in your browser console?

One thing to try is to wrap all of your js in a domready event

$(function() {
    // rest of code here
});

Other than that, I don't know.

1 like
michalurva's avatar

In AJAX you are sending requesteD_id but in your controller you are expecting request_id

1 like
Cronix's avatar
Cronix
Best Answer
Level 67

@michalurva That's true, but would only affect the video count not getting incremented. The modal should still show and with the correct data.

@StephRocks22 Since you named the variable requested_id here

        data : {
            requested_id: user_id
        },

You'll need to change it here too

public function index(Request $request){
    $requested_id=$request->input('request_id'); // needs to be requested_id
     $video = User::where('id', $requested_id)->increment('clicks');
}
1 like
StephRocks22's avatar

@Cronix and @michalurva OMG its finally working! Thank you, especially you @cronix because you've been very patient with me, I know you had to snap at me a little because of how I named my variables but I know you was just trying to help me. Man Thank you guys soooo much! Much love :)

Cronix's avatar

@stephrocks22 You're welcome. Although I'm not sure why you selected the answer you did as the solution. It wasn't why the modal wasn't working, and if you copied my code correctly to begin with you wouldn't have made that naming error since I named it request_id, but you changed it to requested_id.

1 like
StephRocks22's avatar

@cronix I was so excited that I tried to mark all of your answers as the ones that answered my question but I noticed I could only mark one as the answer so I ended up just giving a thumbs up, also I did exactly what you did but I didn't pay attention to the fact that I changed request_id to requested_id but when you guys pointed that out I was like oh that makes so much sense. But again thank you man

StephRocks22's avatar

@cronix I need your help in regards to the video click. I noticed that the view isn't being counted on mobile. I see that when I click the video it just go to full screen it doesn't open the modal. Can you please help me? Thank you

Previous

Please or to participate in this conversation.