<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<script>
function getval(){
var regname ="New South Wales";
$.ajax({
type: "post",
url: 'test.php',
data: {regname: regname},
success: function (response) {
alert(response);
}
});
}
$( document ).ready(function() {
$("#test").click(function(e) {
e.preventDefault();
getval();
});
});
</script>
<button type="button" id="test">Test</button>
</body>
</html>
<?php
if(isset($_POST['regname']))
echo $_POST['regname'];
?>
same page karanawanam mehema tamai karanna wenne
test.php
Code:<?php if(isset($_POST['regname'])) { var_dump($_POST['regname']); exit; } ?> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> function getval(){ var regname ="New South Wales"; $.ajax({ type: "post", data: { regname: regname, }, success: function (response) { alert(response); } }); } $( document ).ready(function() { $("#test").click(function(e) { e.preventDefault(); getval(); }); }); </script> <button type="button" id="test">Test</button>
ajax use කරන්නේ නැතුව මේ විදිහට valu එක pass කරගන්න පුලුවන්.
PHP:$q="<script>document.write(regname)</script>"; echo $q;
එත් $q , mySQL query එකකට දාන්න බෑ.මේකට විසදුමක් තියෙනවද?
ai bari? query eka post karanna
$q="<script>document.write(regname)</script>";
$sql = "SELECT pk_i_id FROM osc_t_region WHERE s_name='".$q."'";
ඒත් හරියන්නෙ නෑ![]()
මෙකෙන් අදහසක් ගන්න පුලුවන් වෙයි
sender.php
<script>
sendData();
</script>
<script>
function sendData(){
var data = "regname=new york";
$.ajax({
type: "POST",
url: "test.php",
data: data,
cache: false,
success: function(result){
alert(result);
}
});
}
</script>
test.php
<?php
echo $_POST['regname'];
?>
ekama page eke karaganna one ban



උබට ඔනේ සේම් පේජ් එකේ ajex වලින් php වලට data transfer කරගන්නද?![]()
ඔව් මචන් Ajax,PHP,JS ඔක්කොම එකම පේජ් එකේ තියෙන්න ඕනේ.
ඔව් මචන් Ajax,PHP,JS ඔක්කොම එකම පේජ් එකේ තියෙන්න ඕනේ.
ඔව් මචන් Ajax,PHP,JS ඔක්කොම එකම පේජ් එකේ තියෙන්න ඕනේ.

" Put your PHP code at the top of the page so no HTML execute before and any PHP code echo.
Add exit() method at the end of the AJAX handler. "
man hithanne meka thamai aula. Thanks machan.mekath try karala balannam
