1

Topic: How to load result php a script without page reboot?

Good afternoon! There is a script on php:
Spoiler: the script Code on php
[spoiler]

<? php
header (' Content-Type: text/html; charset=utf-8 ');
ini_set (' error_reporting ', E_ALL);
ini_set (' display_errors', 1);
ini_set (' display_startup_errors', 1);
$arr_cms=array (
' Questions of a heading a science and technics ' => ' Questions of a heading a science and technics ';
' Questions of a heading computers and the Internet ' => ' Questions of a heading computers and the Internet'
);
// (how many to look forward to hearing a site)
$tm_out=10;//second
function pars_url ($str) {
$str=str_ireplace (' https://', ", $ str);
$str=str_ireplace (' http:// ', ", $ str);
$arr=array ();
$arr=explode ("\n", $str);
$arr=array_unique ($arr);
return $arr;
}
function simple_curl ($url) {
global $tm_out;
$curl = curl_init ();
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_AUTOREFERER, true);
curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, $tm_out);
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($curl, CURLOPT_URL, $url);
$x = curl_exec ($curl);
return $x;
}
function rrr ($str) {
global $arr_cms;
$arr=array (0 =>' ', 1 => ");
foreach ($arr_cms as $a => $ b) {
$pos = stripos ($str, $b);
if ($pos === false)
{} else {
$arr [1] = $b;
$arr [0] = $a;
return $arr;
}
}
return $arr;
}
$f=array ();
if (isset ($ _POST [' url ']) && ($ _POST [' url ']! = ")) {
$arr=pars_url ($ _POST [' url ']);
echo ' <center> ';
foreach ($arr as $a => $ b) {
$content = simple_curl (' http:// '.trim ($b));
$f=rrr ($content);
echo ' Tsms: <b> '. $f [0]. ' </b> ';
echo ' ('. $ f [1]. ') ';
echo ' the Site: <b> '. $b. ' </b> <br> '. "\n";
}
echo ' </center> ';
} else {
echo $frm ='
<html>
<body>
<h1> Enter  </h1>
<form action = "index.php" method = "post">
<textarea rows = "10" cols = "45" name = "url"> </textarea> <br>
<input type = "submit" value = "Go">
</form>
</body>
</html> ';
}

[/spoiler]
The essence in that is entered into a text box of the link of one resource, whether in summary processes a script and produces is under these links of a category or not.
Here for a link example.
http://www.bolshoyvopros.ru/questions/actual/cat10.html
http://www.bolshoyvopros.ru/questions/actual/cat12.html
How to make so that loading happened through ajax? That is at first the first link should undertake and it to be processed. Loading process in a type . Then in the same way the second link.
At present there is a reboot of page and produces ready result at once under both links.

2

Re: How to load result php a script without page reboot?

First of all it is necessary to divide client and server parts.
To implement  on the client:
- Reading of the input data from a text box;
- Their analysis on separate parts and check of a correctness,
- Sending of requests about the server;
- Handling of answers of the server (record of results on page) including error handling;
- Picture show/concealment ;
- Necessarily .
Well and the server scratch is sensitive to file - to replace the answer in the form of a HTML-code on JSON.
Somehow so approximately.