0

i have an div (id="id_content") in Main.html, and an php file "cmp.php" is dynamically loaded by JQuery.load() in "id_content". It is working fine.

However after the "cmp.php" called itself (for updating) using following code : <form action="<?php echo $_SERVER['PHP_SELF']?>" target="_self" method="post" >

the "cmp.php" occupies the complete browser, what i want ist that "cmp.php" is always being displaye in div "id_content".

Thanks in advance.

2 Answers2

0

you can submit form by using Ajax

faltay
  • 83
  • 6
0

The problem is that you are posting the form with the target="_self". This tells the browser that what is returned from the cmd.php should replace the content of the current window.

You have some options:

1) Create an iframe on the main.html like:

<iframe id="postframe"></iframe>

Change the the form to:

<form  action="<?php echo $_SERVER['PHP_SELF']?>" target="postframe" method="post" >

The result of cmd.php will now appear inside the iframe when you submit.

2) Use Jquery to post/get your form data and handle the result in Javascript.

<form id="yourform">

</form>

$("#yourform").on("submit",function(e){
   //Called when you hit submit
   e.preventDefault(); //Don't post the form
   //Create a request from form variables and send to server.
   //Depending on the result alter id_content.
   return false;
});
Niclas
  • 1,306
  • 5
  • 15
  • 28