Reputation: 2197
Helo.... I need to submit a form. In the same time with the same submit button I need to load the relevant php file in to a target div. This is an dummy question that I have tried.
<form id='A' method="POST" action="CreateTheForm.php">
<input id="B" name="R"></input>
<input id="C" name="SubmitBtn" type="submit" value="loading the vaue"></input>
</form>
$(document).ready(function(){
$("#C").click(function() {
$("#Loading_Page").load('CreateTheForm.php');
return false;
});
});
But though I can load the CreateTheForm.php file to the Loading_Page div, the data are not posting and I cant access them from CreateTheForm.php file.
What I need to do is first I should post data to the php file and load it to the relevant div with the same click. How can I make this possible.
This works well without the load function.
Upvotes: 0
Views: 851
Reputation: 5007
Just make a $.post Request and grab the content as:
$(document).ready(function(){
$( "#C" ).click(function() {
$.post( "CreateTheForm.php", { R: $('#B').val() }, function(data){
$('#Loading_Page').html(data);
});
return false;
});
});
Upvotes: 1
Reputation: 9199
you can use this
$( "#C" ).click(function() {
$("#Loading_Page").load('CreateTheForm.php');
$("#a").submit();
return false;
});
Upvotes: 1
Reputation: 831
You are not posting the data. To post the data you will need to use this.
$("#Loading_Page").load('CreateTheForm.php', {'R': $('#B').val()});
instead of
$("#Loading_Page").load('CreateTheForm.php');
Upvotes: 1
Reputation: 74420
Try that:
$("#C").click(function () {
$("#Loading_Page").load('CreateTheForm.php');
$(this).closest('form')[0].submit();
return false;
});
Upvotes: 0