I am calling a javascript fetch function through the onsubmit event of form. the form description is as
<formid="cpn_input_form"style="margin-top:50px;"autocomplete="off-"onsubmit="cpnInputSubmit(this)">
The fetch function is as
awaitfetch( window.location.origin + pathname,
{method: 'POST', // or 'PUT'
mode: 'cors',
credentials: 'include',
redirect: 'follow', // manual, *follow, error
referrerPolicy: 'no-referrer',
headers: {'Content-Type': 'application/json', },
body: JSON.stringify(data), })
.then((response) =>response.json())
.then((data) => {returndata
})
.catch((error) => {console.error('Error:', error); });
This function is not hitting the route that is defined in controller file.
I am looking forward to your response. Please guide me.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Buchhaltung
- Lager
- PoS
- Project
- MRP
Diese Frage wurde gekennzeichnet
It sounds like there may be an issue with the JavaScript fetch function that you are using to submit the form data to the server.
Here are a few things you can check to troubleshoot the issue:
Verify that the pathname variable in the fetch function is correctly defined and points to the correct route on the server.
Check that the route on the server is correctly defined and configured to handle the 'POST' request sent by the fetch function.
Make sure that the data passed in the body of the fetch function is in the correct format and that it matches the data expected by the server route.
Verify that the 'Content-Type' header is correctly set to 'application/json'
Check that the server is running and that there is no issue with the server.
Check that there is no issue with the network.
Check that the browser you are using support CORS (Cross-Origin Resource Sharing)
Check that the browser is not blocking the request.
It may be helpful to add some console log statements in the fetch function and the server side code to see where the request is failing. Additionally, you may want to check the browser's developer console for any error messages.
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
RegistrierenVerknüpfte Beiträge | Antworten | Ansichten | Aktivität | |
---|---|---|---|---|
|
1
Juli 24
|
1435 | ||
|
1
Juni 24
|
2391 | ||
|
1
Juni 24
|
1434 | ||
|
2
Juni 24
|
4357 | ||
|
1
Juni 24
|
1994 |