Skip to content

How do I create a simple AJAX call where I can toggle a value without reloading the page #2843

Closed Answered by eleybourn
eleybourn asked this question in Q&A
Discussion options

You must be logged in to vote

I've sorted it out.

I sorted it out. For anyone else who's having a similar challenge, this is what I did.
In resources/js/controllers/flip.js
Note: I'm extending ApplicationController (which is loaded as window.Controller) to access the native Orchid AJAX call (loadStream).

//flip.js
export default class FlipController extends window.Controller  {

    asyncLoadData({ params: { route, company, session}} ) {
        var data = {"company_id": company, "session_id": session};
        this.loadStream(route, data);
    }
}

Append to resources/js/app.js (the Orchid website instructions say dashboard.js, but app.js exists instead)

import FlipController from "./controllers/flip"

application.re…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by eleybourn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant