2
First of all I have looked in several other posts on the subject here and I did not find what I need, my scenario is the following I am generating several EX links:
challenge.php? id=2&name=Joao
challenge.php? id-3%name=Jose
and I need to pass this via ajax to my php page that processes it. however the page is not getting the data what can be? follows my code
urls generated
<a id='desafiar' href='desafiar.php?idd={$linha['id']}&d={$linha['username']}'></a>
script
$(document).ready(function() {
$("#desafiar").click(function( e ) {
e.preventDefault();
var url = $( this ).attr('href');
$.ajax({
cache: false,
type: "POST",
url: "desafio.php",
data: {url},
success: function( data ){
$("#resultado").html( data );
}
});
});
});
in the page that picks up php
$iddesafiante = $_SESSION['user_id'];
$desafiante = $_SESSION['username'];
$iddesafiado = $_GET['idd'];
$desafiado = $_GET['d'];
open to suggestions
Possible duplicate of send the javascript variable to php
– KhaosDoctor
You’re using
type: "POST",
in Javascript and$_GET
in PHP. You have to use the same in both.– Sergio
@Khaosdoctor I voted to leave open, because despite the problems seem, are different things, in the link that posed the problem is "send the variable", in this case the difficulty is with GET and POST, which makes a different problem.
– Guilherme Nascimento