title: How to Submit a form and load target page inside a Div on the Current page?
body: <p>I am new to Javascript and didn't arrive to find a working script that does the following:</p>
  
  <p>I have a hidden form in javascript that should be submitted on an onclick event. The fields in the form are used in the target php file to create output. The target php file should be loaded inside a div on the current page without reloading the whole page. </p>
  
  <p>The problem is that I cannot get the target php file to load inside the div on the current page, but the target php page is simply loaded showing the results that I want to have inside the div.</p>
  
  <p>Any help would be very appreciated!</p>
  
  <p>Update #1</p>
  
  <p>I did a youtube tutorial on jquery ajax request where the result is shown in a div on the same page. I double checked the code many times and it looks the same as in the tutorial. In the tutorial the code is working but for me it isn't. Below are all the files I'm using and the code.</p>
  
  <p>ajax.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
  //
  $(document).ready(function(){
  
  $("#button").click(function(){
  var sendu = $("#username").val();
  var sendp = $("#password").val();
  
  $.ajax({
  type="POST",
  url: "ajax.php",
  data: "username="+sendu+"&amp;password="+sendp,
  dataType: "json", 
  success: function(msg,string,jqXHR){
  $("#result").html(msg.name+"&lt;br /&gt;"+msg.password);
  }
  });
  });
  });
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  Name:&lt;input type="text" id="username" name="username" /&gt;&lt;br /&gt;
  Password:&lt;input type="password" id="password" name="password" /&gt;&lt;p&gt;
  &lt;input type="button" id="button" value="submit" /&gt;
  &lt;p&gt;&lt;div id="result"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>jquery.js from this url:
  <a href="http://code.jquery.com/jquery-1.6.2.min.js" rel="nofollow">http://code.jquery.com/jquery-1.6.2.min.js</a></p>
  
  <p>ajax.php:</p>
  
  <pre><code>&lt;?
  
  $name = $_REQUEST['username'];
  $password = $_REQUEST['password'];
  
  $list = array('name'=&gt;$name, 'password'=&gt;$password);
  
  $c = json_encode($list);
  
  echo $c;
  ?&gt;
  </code></pre>
  
  <p>I'm using the WAMP server as my localhost, could it have anything to do with a setting?</p>