#Problem with sending URL by thymeleaf and JS. Spring boot application

1 messages · Page 1 of 1 (latest)

wide bay
#

I have file where I have form and some JS scripts. I only want to send products/save/clientId/params
but when I do its sending another url - show/ from my form above in this file. How to fix it? Full file to download.

function saveProducts() {

const pathname = window.location.pathname;
const pathSegments = pathname.split('/');
const clientId = pathSegments[pathSegments.length - 1]; // Get the last segment
const urlParams = new URLSearchParams(window.location.search);
uri = save/${clientId}?${urlParams};

    $.ajax({
        type: "GET",
        url: uri,
        success: function(result) {
        console.log("Udalo sie!");
        }
        });
        }
buoyant gazelleBOT
#

<@&987246452180930620> please have a look, thanks.

buoyant gazelleBOT
karmic crag
buoyant gazelleBOT
buoyant gazelleBOT
#

@wide bay

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍

buoyant gazelleBOT
#

@wide bay

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍

wide bay
#

Still need help

wide bay
#

Yes, it was the same situation with this code

#

It looks like its still shows two addresses at once. It was working about month ago and unfortunately...

#

Wait... its something another now

buoyant gazelleBOT
#

@wide bay

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍

wide bay
# karmic crag Did u ever try

yes, I tried, and it wasn't working. I found today a reason: the addres uri was not full.... it need to be uri = /products/heatpumps/save/${clientId}?${urlParams};

But now I have another error. Its working to send this get request and it is saving Heat Pump to Client but on the screen I see: error 400

I don't know why I see this error. I think about controller return:
return "redirect:/salesmen/clients/" + salesmanId.toString();
But I don't see any this redirect problems here. It is doing full code of /products/heatpumps/save controller. Can you help me?

karmic crag
#

Show the full http request log (as im click the error/link on the left and get the full url and payload, and also show the corresponding controller

#

for example

wide bay
#

After sending my get ajax its still going to use address /products/heatpumps/show - not save, and its show 400
but this save ajax works... and this is problem

#

One more pic with this two errors. It shows /products/heatpumps/show with params too

#

so my screen is now:
and in controller all is working

#

Now I'm not going go anywhere so I will give you fast responses, Xorium

#

maybe with pathsegments its something here?

karmic crag
#

you should have some console log from the app itself. it should give more insight

wide bay
#

at this moment this have same console.logs I putted it few days ago:
and its not shows

#

also this:

#

In console we have only it:

#

I'm thinkig about build this page in another way but I know we are near to solve this.

karmic crag
#

i mean in the java code. Its a 400, its hitting the method in some way

#

that one is a bad request because it has no query parameters provided (all 3 are required)

#

but idk why the other failed

wide bay
#

In java I have many console.log. I don't know for what info from it you are looking for

#

How do you think to solve this...? Maybe create new page, I don't want to play with it so many time

#

I need to create form to search, show and save heatpump to client

karmic crag
#

spring logs its own errors

#

when you try to make that request to products/heatpumps/show it will fail in the spring output with why

#

such as "failed to bind 'productId'"

wide bay
#

but when I'm doing this show http first time its works - its show this heat pump on the map, but after doing ajax save it is try http show second time but without params..

#

And when I'm hitting zapisz urzadzenie button its produces this show without params and realize this save ajax

#

I don't know why its sending show http second time...

karmic crag
#

I will be off work soon if you want to screenshare the issue in one of the support channels

wide bay
#

which channel? its any easy way to screenshare this topic?

karmic crag
#

one of the #272767658468966400

#

but it'll be easier to see the network log live

wide bay
#

okey, thanks Xoirum for your support. I hope that if you will be back it will be solved.

karmic crag
#

ok i joined a voice channel