单击仅刷新div

After i click the button i want to refresh only <div class="wrap"> ... </div> With this window.location.reload() but i refresh whole page, so i need a ajax script that will refresh only that div.

<div class="wrap">

    // Content

    <div class="random_dil">
    <a class="button" onclick="window.location.reload()" href="#">Sljedeće pitanje</a>
    </div>

I tried this

<div id="mydiv"></div>
<a id="refresh">click</a>

<script>
$(function() {
  $("#refresh").click(function() {
     $("#mydiv").load("http://blah.com/page.php")
  })
})
</script>

But this again refresh whole site.

$.ajax({
    url: "http://blah.com/page.php",
    async: true
}).done(function(result) {
    $("#mydiv").html(result);
});

If you are saying that the entire page is being recreated inside the mydiv area, IE click is added into my div when you click it. It is because that is what page.php is providing, jquery can select only a portion of the page to do that change the third line of your scrip to.

$("#mydiv").load("http://blah.com/page.php #mydiv" );

In your 2nd "also tried" example.

<script type="text/javascript">
function GetXmlHttpObject()
{
  if (window.XMLHttpRequest)
  {
    return new XMLHttpRequest();
  }
  if (window.ActiveXObject)
  {
    return new ActiveXObject("Microsoft.XMLHTTP");
  } 
  return null;
}

function ajax_function(url, postData, id)
{
xmlhttp=GetXmlHttpObject();
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", postData.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=function()
{
    if(xmlhttp.readyState==4)
    {
          document.getElementById(id).innerHTML=xmlhttp.responseText;                            
    }       
}                
    xmlhttp.send(postData);
 }

 function refreshDiv()
 {
var params = '';
var DivId  = 'wrap';
    var url    = 'http://blah.com/page.php';

ajax_function(url, params, DivId);
 }
 </script>

HTML

<div class="wrap">

// Content

<div class="random_dil">
<a class="button" onclick="refreshDiv()" href="#">Sljedeće pitanje</a>
</div>