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

cwray-tech's avatar

Ajax request is reloading page and adding query strings to uri

I have created a review system, which is working and I have Vue components that make ajax post requests to my review controller. Everything is working, except whenever the form is submitted, it makes a full post request to the site, and reloads the page. It also adds a query string to the uri "body=test" etc.

What am I doing wrong here?

You can see the website here, but you will have to login to test the review functionality: https://www.nurserypeople.com/nurseries/garden-gate-nursery-llc

0 likes
5 replies
Snapey's avatar

Is your form using GET rather than POST? Sounds like you did not prevent the default form action when you sent the ajax request

1 like
wingly's avatar
wingly
Best Answer
Level 29

Assuming that you have a element in order to submit it by ajax you gonna need to do <form @submit.prevent="yourmethod">

1 like
cwray-tech's avatar

@snapey and @wingly Really appreciate your help. that fixed the problem. Would one of you have time to look at my reviews component and see why it is not passing events from child component to parent right? I would pay you for your time that you spend going through it with me.

wingly's avatar

Just create a new thread in laracasts and describe your problem i am pretty sure that you won't have to pay anyone

1 like

Please or to participate in this conversation.