Loading a URL and passing a variable into the new window


#1

I’m trying to load a URL and pass a variable to the new window using synchronous messages.
This is the code I’m using in my renderer:

$("#movies").on("click", ".movie", function() {
        var imdb = $(this).children('input').val(); // the value I want to pass
        const reply = ipc.sendSync('load-movie', imdb);
        $('#imdb').text(reply); // trying to set the text of my div to this value
});

And this is the code in my main:

ipc.on('load-movie', function(event, arg) {
        mainWindow.loadURL('file://' + __dirname + '/movie.html?imdb=${arg}'); //loading the new URL
        event.returnValue = ${arg}; //returning the imdb id in order to set it to my div's text
})

The problem is that although the new URL loads, I get no response returned from the main.
There certainly must be a better way of loading a URL and passing a variable into the new page, but I can’t think of one.
Thanks in advance!