I am having a php page that take in a parameter e.g
mypage.php?keyword=SOMEVALUE
But the keyword is an ajax value that user enter at a html form which run with jQuery.
I need to like let the user enter the value in a text field , and retrieve data from mypage.php
and set it into the value of field1.
How do I do it? I see that some site mention javascript respect same origin policy, what should I do?
Now I got 2 files
UPDATED AGAIN
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>demo</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#filter").click(function(){{
var self = this;
//The following mostly from Olaf's answer
$.ajax({
url : 'jquery2.php',
dataType : "html",/* JSON, HTML, SJONP... */
type : "get", /* POST or GET; Default = GET */
data:{
keyword : $(keyword).val() /* $(self) = $("#keyword") */
},
success : function( response )
{
/*
* on input
*/
$("#keyword").val( response )
/*
* on html
*/
$("#newhtml").html( response )
}
});
});
});
</script>
</head>
<body>
<input type="text" name="keyword" id="keyword" />
<input type="button" id="filter" name="filter" value="Search Data" />
<div id="newhtml"></div>
</body>
</html>
jquery2.php
<?php
$keyword = $_GET['keyword'];
echo "keyword is " . $keyword;
?>
I changed my jquery.php to this code. but still fail to retrieve the output from jquery2.php , the textfield value does not change to jquery2.php output.
Thanks for helping