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

arcanaer's avatar

Non-cancellable requests with inertia

Hello, i'm developing with inertia, but i noticed that inertia cancel the previous requests if new is maked.

I need the "realtime" functionality, like when user types, it is automatically updated in database. The problem is that the user can upload images or videos, and the user can follow writing, so if the user follow writing while image is uploading, the request is canceled and image is not uploades. Anyone know how can i make async requests or something like that? Im using useForm helper from inertia.

This is a video to explain better https://drive.google.com/file/d/14x2xk7mmcPcjyCtFoYSyaTF_cKzZ0ZlF/view?usp=sharing

const form = useForm({
        media_to_upload: [],
        media_to_delete:null
    });

    /**
     * Methods
     */
    const uploadMedia = (files) => {
        form.media_to_upload = files
        form.media_to_delete = null

        form.post(route('posts.media.upload', {'post':props.post.id}),{
            preserveScroll:true,
            preserveState:true,
        })
        form.media_to_upload = []
    }
0 likes
3 replies
MohamedTammam's avatar
Level 51

When working with Inertia act like you're working with normal monolith app and not with SPA.

Inertia forms act like normal HTML forms, you can submit only one at a time.

To achieve your purpose you can use normal AJAX requests with an API endpoint in the back-end. Don't use useForm from Inertia if you're doing multiple requests.

1 like

Please or to participate in this conversation.