I'm currently trying to send data to the same page using the selected value in a table row. The user selection gets highlighted and then when the button's onsubmit event is fired, the script is run.
I'm trying to retrieve the $_POST
data on the same page, in order for the user to see a new form that they need to fill out and not showing the previous table anymore, but I never get to the inside of an if
statement that checks if it isset lik this:
isset($_POST['xx'])
I really don't know what I'm doing wrong here. This is my code so far:
$(".mypost").on("click",function(){
$.ajax({
url: "../ajout-correctifs/",
type: "POST",
data: { selectedcoll: $("#MyTable1 tr.selected input").val()},
success: function(response){
window.location = "../ajout-correctifs/";
//alert(response);
},
error: function(){
alert("POST METHOD ERROR : DATA NOT POSTED - IMMINENT PAGE RELOAD..");
window.location = "../ajout-correctifs/";
}
});
});
Additional Information:
- the
$("#MyTable1 tr.selected input")
is what helps me retrieve whatever the user has selected. - the
alert("response")
displays html code
EDIT : Here is my php file :
https://raw.githubusercontent.com/SofiaEO/mypage/master/mycode.php
EDIT : SOLUTION in case someone else has the same issue
I deleted the url
value + I used $('body').html(response)
to print the page.