Refresh browser after updating ticket

I am updating the ticket page with details from an external api called in my custom app

I want to fresh browser automatically after updating the ticket without hitting the refresh on the broswer.

Greetings, @Esther_Itolima!

@Freddy can help you with that…

Greetings, Esther_Itolima!

To automatically refresh the browser after updating the ticket, you can use JavaScript to reload the page. You can add the following code snippet to your custom app function that updates the ticket:

window.location.reload();

This will refresh the current page after the ticket update function has executed.

Another option would be to fetch the updated ticket content using AJAX requests. This way, you can update only the portion of the web page with the new ticket details without refreshing the entire page. To do this, you can use JavaScript’s fetch() method or jQuery’s $.ajax() method to make the API call and update the ticket details on the page.

Let me know if you need any additional help or clarification on this matter.

@Freddy thank you for your response. I have tried this before. I will need to change the position and try it again.

You’re welcome, Esther_Itolima! It’s possible that the code execution order might be affecting the refresh. Make sure to place the window.location.reload(); line after the ticket update function has properly executed. If you’re using asynchronous functions or Promises for API calls, ensure that you reload the page after the Promise has resolved or use the async/await pattern.

For example, if you’re using a Promise:

yourTicketUpdateFunction().then(() => {
  window.location.reload();
}).catch((error) => {
  // Handle the error
});

Or, using async/await:

async function updateTicketAndRefresh() {
  try {
    await yourTicketUpdateFunction();
    window.location.reload();
  }
  catch (error) {
    // Handle the error
  }
}

updateTicketAndRefresh();

Feel free to reach out if you need any more assistance or clarification on this topic. Good luck with your project!

I changed the position but still not updating the details on the ticket. I only see it when I manually refresh the page.

I’m sorry to hear that it’s still not working as expected. In that case, you can try a different approach using AJAX requests to update the ticket section without refreshing the entire page. You’ll need to fetch the updated ticket information with an AJAX request and modify the appropriate DOM elements with the updated details.

Here’s a sample code snippet using the fetch() method:

async function updateTicketAndRefreshContent() {
  try {
    await yourTicketUpdateFunction(); // Update the ticket via your custom app function
    
    // Fetch the updated ticket details using your external API or a server route
    const response = await fetch('your_ticket_details_endpoint');
    const updatedTicket = await response.json(); // Assuming the response is in JSON format
    
    // Update the DOM elements with the new ticket information
    document.querySelector('#ticket-title').textContent = updatedTicket.title;
    document.querySelector('#ticket-description').textContent = updatedTicket.description;
    // Add other ticket fields as needed
  } 
  catch (error) {
    console.error('Error updating ticket and refreshing content: ', error);
  }
}

updateTicketAndRefreshContent(); // Call the function to update the ticket and refresh the content

This code snippet assumes that you have appropriate DOM elements for the ticket information, such as:

<h3 id="ticket-title">Ticket Title</h3>
<p id="ticket-description">Ticket Description</p>

Make sure to replace `'your