I want to pass two input data to PHP with JQuery ajax I read about json, serialize and similar but I couldn't quite get a grip around it. I got:
<p><input type="text" id="domain"></p>
<p><input type="text" id="domain1"></p>
<button id="order">Search</button>
<script type="text/javascript">
function callAjax() {
$.ajax({
type: "GET",
cache: false,
url: 'getip.php',
data: ???
});
</script>
And also what do I need on PHP file because I only got this.
$name=($_GET['']);
$surname =
echo($name) ;
endif;
3 Answers 3
function callAjax() {
// Get values to send to server
var domain = $('#domain').val();
var domain1 = $('#domain1').val();
$.ajax({
type: "GET",
cache: false,
url: 'getip.php',
data: {
domain: domain,
domain1: domain1
}
And in php you'll get it as
$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
answered May 12, 2015 at 14:27
Tushar
87.4k21 gold badges164 silver badges182 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
$.ajax({
type: "GET",
cache: false,
url: 'getip.php',
data = {
'domain': $('#domain').val(),
'domain1': $('#domain1').val()
};
)};
And in you php file php you can get data with :
$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
answered May 12, 2015 at 14:29
Ahmed Ziani
1,2343 gold badges14 silver badges26 bronze badges
Comments
Try this:-
<p><input type="text" id="domain" name = "domain"></p>
<p><input type="text" id="domain1" name ="domain1"></p>
<button id="order">Search</button>
function callAjax() {
$.ajax({
type: "GET",
cache: false,
url: 'getip.php',
data:{domain: $('#domain').val(),domain1: $('#domain1').val()}
});
In your php file get it like this:-
$domain = $_GET['domain'];
$domain1 = $_GET['domain1'];
Note:- Please try to read jquery a bit. It will help you.
answered May 12, 2015 at 14:30
Death-is-the-real-truth
72.3k10 gold badges59 silver badges106 bronze badges
3 Comments
user3187715
When i try to read documents on jquery its like reading Arabic or chinese, i always need to see live example, just my style of learning i will try this tough :). See how it works
Death-is-the-real-truth
then mark it as your answer. It helps other to get there solutions.
user3187715
Oh i thought i did :).
default
$( document ).ready(function() { // code here });OR$(function() {//code here });callAjaxfunc