Hello. There are cms amxbans how to make a change of content without reloading the page, output from other files.

Closed due to the fact that the issue is too general for the participants Alexey Shimansky , Denis Bubnov , Alex , user194374, rjhdby 19 December '16 at 8:05 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .



    2 answers 2

    Look away - javascript jQuery Ajax

    • I know this article do not tell me? - bajex
    • one
      @bajex here should be a question about whether you can use Google - DreamChild
    • one
      You are joking? Have you been banned on google? Maybe you do not know how [the request to make] [1]? [1]: bit.ly/17zmcaJ - Deonis
    • @bajex, jquery.com - Konstantin Choporov

    To do this, use AJAX - requests.

    The code I use for this purpose is:

     function send_request(r_method, r_path, r_args, r_handler) { var Request = false; if(window.XMLHttpRequest) { Request=new XMLHttpRequest(); } else if (window.ActiveXObject) { try { Request = new ActiveXObject("Microsoft.XMLHTTP") }; catch(CatchException) { Request=new ActiveXObject("Msxml2.XMLHTTP"); } } if(!Request) { return; } Request.onreadystatechange=function() { if(Request.readyState==4) if(Request.status==200) r_handler(Request.responseText); if(r_method.toLowerCase() =="get"&&r_args.length>0) r_path+="?"+r_args; Request.open(r_method,r_path,true); if(r_method.toLowerCase()=="post") { Request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"); Request.send(r_args) } else { Request.send(null) } } } 

    Briefly about the arguments:

     send_request("Тип запроса. get либо post","Путь/к/файлу.php","Аргументы. Например: topic=46764&page=4",function(response){ //Код, который будет исполняться при успешном окончании запроса //response - переменная, содержащая ответ }) 

    A small example:

    test.html

     <html> <head> <script> function send_request(r_method, r_path, r_args, r_handler) { var Request = false; if(window.XMLHttpRequest) { Request=new XMLHttpRequest(); } else if (window.ActiveXObject) { try { Request = new ActiveXObject("Microsoft.XMLHTTP") }catch(CatchException) { Request=new ActiveXObject("Msxml2.XMLHTTP"); } } if(!Request) { return; } Request.onreadystatechange=function() { if(Request.readyState==4) if(Request.status==200) r_handler(Request.responseText); if(r_method.toLowerCase() =="get"&&r_args.length>0) r_path+="?"+r_args; Request.open(r_method,r_path,true); if(r_method.toLowerCase()=="post") { Request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"); Request.send(r_args) } else { Request.send(null) } } } function request() { send_request("GET", "test.php", "testval=test", function(response) { document.body.innerHTML+=response }) } </script> </head> <body> <button onclick="request()">Загрузить!</button> </body> </html> 

    test.php

     <?PHP echo "Тестовая переменная: ".$_GET['testvar']; ?> 

    You can add unlimited variables. Changing the content can be done by forcing the PHP script to give out the html code, and later changing the innerHTML of a block in response. This option is the easiest. There is a more complicated option, with JSON, but that is another question.