ive got 2 different php files.
first one: A.php
, second : B.php
in A.php, ive got this line:
function altcat(id) {
jQuery("#tvspor2").load("B.php?arupa="+id+"");
}
let me explain what im doing in the A.php:
i ve got a link in the A.php: <a href='javascript:altcat("5")'>
so, if a user click this link, A.php send this value to B.php?arupa=. its so simple. and B.php has this line:
if ($_GET["arupa"]) {
echo $_GET["arupa"];
}
in the A.php i ve got this line: <div id="tvspor2"></div>
so, it开发者_运维知识库 shows the result.
for example: if a user clicks the link, result will show 5.
here is my question: i can show result in a div. i want to show result as a link. well, i want to use result value like that: <a href="-i want to display altcat(id) to here.-">test link</a>
so, i will able to create dynamic links upon the user choices. can you please kindly show me a way? ive been working on this issue for almost 3 days :( regards
Use .ajax call not load, then just
function altcat(id){
$.ajax({
type: "GET",
url: "B.php",
data: "arupa=" + id,
success: function(data){
jQuery("#tvspor2").html(data);
}
});
}
function okaycity(id){
$.ajax({
type: "GET",
url: "B.php",
data: "bule=" + id,
success: function(data){
jQuery("#tvspor").html(data);
}
});
}
function thirdlink(arupa, bule){
$.ajax({
type: "GET",
url: "B.php",
data: "arupa=" + arupa + "&bule=" + bule,
success: function(data){
jQuery("#tvspor").html(data);
}
});
}
and that should be it if I have understood the question right. You need to echo HTML anchor in B.php not just number.
$arupa = intval($_GET["arupa"]);
if(!empty($arupa)){
echo '<a href="'.$arupa.'">Link</a>';
}
$bule = intval($_GET["bule"]);
if(!empty($bule)){
echo '<a href="'.$bule.'">Link</a>';
}
if(!empty($arupa) && !empty($bule)){
echo '<a href="'.$arupa.''.$bule.'">Link</a>';
}
精彩评论