V
V
vaflya2015-10-18 21:53:17
PHP
vaflya, 2015-10-18 21:53:17

How to submit a page via ajax?

The bottom line is that I load the page using AJAX (for example, info.php), after loading, you need to change the title of the browser tab and load inf.js.

As I understand it, I need to send a json array using php:

{
title : 'Info',
src : 'inf.js'
page : here is the whole info.php page
}


Accordingly, then dynamically change the title, load js, and insert the page into the block.

ps I also heard that instead of a page, just data is transmitted, and then the entire block is rendered on js with the introduction of the received data.

Am I right? Are there better methods? What to google?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2015-10-18
@vaflya

If you need to make a site where there is no transition between pages, but all of them are loaded via AJAX - try using libraries for building SPA sites like AngularJS .
If you want to do it manually, then at least transfer not the entire page, but only the part that changes - the content. And do not forget that even in the answer it is worth considering the possibility of errors.
That is, it might look like this:

// Грубый пример
{
  "status": "ok",
  "data": {
     // Ваши данные
  },
  "errors": []
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question