-2

i am trying to load ticket.htm from holiday.html using ajax. when i click on "Get Ticket" it is supposed to slide the para from ticket.htm but i am getting nothing .All i can see is a button.so far my script went like this..

<script>
    $(document).ready(function()
   {
    $("#button").on('click','#submit',function()
         {
            $.get("ticket.htm",function(response)
           {
            $('#content').html(response).slideDown();
           });
        });
    });
 </script>

 <body>
   <div id="button">
       <input id="submit" type="submit" value="Get Ticket"/>
   </div>

     <div id="content">
     </div>
 </body>    

ticket:

  <p class="button-para">Flight Details: Air Asia<br>
                Schedule: 20-01-2015 (10:15 AM)<br>
                Gate C
  </p>

1 Answers1

0
$('#content').html(response).slideDown(); // appending response to the newly added div

<body>
 <div id="button">
       <input id="submit" type="submit" value="Get Ticket"/>
 </div>
<div id="content"></div> // Added a new div with id content 
</body>  

EDIT: This issue was due to calling xmlhttp request (AJAX) without using a webserver. Once the xampp (apache,php,mysql) is installed the problem solved

Kiren S
  • 3,037
  • 7
  • 41
  • 69
  • what is your response? Did you alert it? or console.log(response) – Kiren S Jan 02 '15 at 08:19
  • error(console) :XMLHttpRequest cannot load file:///C:/Users/Abhiram1214/Documents/HTML/jquery/ticket.htm. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource. – user3484925 Jan 02 '15 at 08:28
  • Do you have your webserver installed?xampp/wamp – Kiren S Jan 02 '15 at 08:35
  • This will help you http://stackoverflow.com/questions/8449716/cross-origin-requests-are-only-supported-for-http-but-its-not-cross-domain – Kiren S Jan 02 '15 at 08:42
  • :tried with xampp server which resulted in following error. No 'Access-Control-Allow-Origin' header is present on the requested resource. – user3484925 Jan 02 '15 at 14:21
  • $.get("localhost/pathto/ticket.htm",function(response) – Kiren S Jan 02 '15 at 15:34