HI,
ich habe eine einfache Datenbank auf einem Server. Dieses PHP Skript liegt auf dem Server und funktioniert wenn ich die Url aufrufe( http://**.com/search.php?id=a10 ) Als Echo kommt „33 raus“
[PHP]<?php
$pdo = new PDO('mysql:host=*com; dbname=*test1', '*', '*');
$idV = $_GET['id'];
$statement = $pdo->prepare("SELECT position FROM idtabelle WHERE idnumber = :idV");
$statement->bindParam(':idV', $idV);
$statement->execute();
while ($row = $statement->fetch(PDO::FETCH_ASSOC))
{ $posV = $row['position']; };
echo $posV;
?>[/PHP]
Ich möchte nun, wenn ich auf einem Button drücke, soll das Echo irgendwo ausgegeben werden. z.B in einem DIV. Das muss mit Ajax und GET gehen aber es funkltioniert bei mir nichts.
[HTML]
Info Button
<script>
$(document).ready(function() {
$("#bt1").click(function() {
$.ajax({
//create an ajax request to load_page.php
type: "GET",
url: "http://**.com/search.php?id=a10 ",
dataType: "html", //expect html to be returned
success: function(response){
$("#div1").html(response);
alert(response);
}
});
});
});
[/HTML]
Danke