Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
103
rated 0 times [  110] [ 7]  / answers: 1 / hits: 49519  / 9 Years ago, wed, november 25, 2015, 12:00:00

Before going to the specific question I need to explain a few basic steps.



First, the application in question deals with the management of appointments online by customers.



The customer after filling a form with the treatments for the beauty center and providing their information comes to the confirmation page.



Now this page performing an ajax request to store the appointment on the database.



If everything is successful is shown a page containing the details of the appointment with the success message.



The problem is that the page is currently displayed only in the response, that is, in the tab network console browser.



So my question is simple: How can I replace the entire structure of the html page with actual one shown in the response?



I found a lot of questions on the web even on StackOverflow. But all of this is limited on an append to a div. I do not need to hang but also replace the <html>, how to rewrite the html page. I have no idea how to do this and I need some advice from you.



For completeness, this is the code that comes back to me ajax response html:



       $.ajax({
'type': 'POST',
'url': 'backend_api/ajax_save_appointment',
'data': postData,
'success': function(response)
{
console.log(response);
},
'error': function(jqXHR, textStatus, errorThrown)
{
console.log('Error on saving appointment:', jqXHR, textStatus, errorThrown);
}
});

More From » php

 Answers
91

If your response includes the <head> and <body> tags:



$(html).html(response);.



If not, and it's only content, then do:



$(body).html(response);.


[#64276] Monday, November 23, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
harleyaleenag

Total Points: 678
Total Questions: 121
Total Answers: 105

Location: Papua New Guinea
Member since Thu, Jul 9, 2020
4 Years ago
harleyaleenag questions
Thu, May 5, 22, 00:00, 2 Years ago
Wed, Aug 19, 20, 00:00, 4 Years ago
;