0

I'm trying to load a .html file in a other html file ManageAccount page should load in a div with id main, when manage acount is clicked, but it loading the whole page again in div. enter image description here Result is fethching all the html page insted of new html page can any one suggest me please.

<script type="text/javascript">
    $(document).ready(function(){
      var btn;
      $('button[type="button"]').click(function() { 
        btn = this.id;
        alert(btn);
        $.ajax({
          url: btn.html,
          type: 'GET',
          //async:'false';
          dataType: 'html',
          success: function(result){
            $("#main").html(result);
            alert(result);
          }
       });

      });
    });
</script>

Manage Account Profile Application Status Query
4
  • 1
    In your ajax call you must pass in the url as a string url: "btn.html" Commented Jul 23, 2015 at 10:31
  • btn is button id the name is generated on which button is clicked like btn=profile so it will load profile.html. Commented Jul 23, 2015 at 10:37
  • So you should type btn + '.html' Commented Jul 23, 2015 at 10:40
  • If you consider that one of the answers is valid, please, mark it as valid to help others to find similar problems and solutions. @rikky Commented Jul 23, 2015 at 15:58

2 Answers 2

1

You have to wrap in quotes at least the extension of the file url: btn + '.html'.

Also, you can use jQuery .load() method directly:

$('#main').load(btn + '.html');
Sign up to request clarification or add additional context in comments.

Comments

0

Try using jQuery.load()

 $('button').on("click", function() { 
       $("#main").load("btn.html"); 
 });

1 Comment

i tried with load but problem is, it is not working in chrome $("#btn1").click(function(){ $("#main").load("manageAccount.txt"); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.