0

I use JQuery AJAX. I need to send some data to page, than receive data, remove all tag (include html), and set new page like this:

<html>
<head></head>
<body>Example</body>
</head>

I use this JQuery script:

 $.ajax({
  type: "POST",
  url: "some.php",
  data: "name=John",
  success: function(msg){
    //how remove and set new page?
  }
 });
6
  • 4
    Why not simply redirect to the new page? Commented Jul 12, 2013 at 10:50
  • 4
    That sounds like a terrible idea compared to a normal postback, which does just about the same thing. Commented Jul 12, 2013 at 10:50
  • Pardon me, but what sense does this make if you want to remove as much as html tag? What difference does this make from simply loading a new page? Commented Jul 12, 2013 at 10:51
  • If you need to overwrite the entire page, you should simply use window.location = url. Commented Jul 12, 2013 at 10:51
  • 2
    @HiteshSiddhapura This is bad advice. You should never be replacing the body with new content returned from ajax Commented Jul 12, 2013 at 10:58

1 Answer 1

1
$.ajax({
  type: "POST",
  url: "some.php",
  data: "name=John",
  success: function(msg){
    window.location = 'your/new/page/url';
  }
 });
Sign up to request clarification or add additional context in comments.

Comments

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.