Jump to content

How do I send data and return data from the server-side PHP, properly?


Masonh928

Recommended Posts

Here's the code that deals with the client side:

<?php 
session_start(); 
if(!isset($_SESSION['Logged_in'])){
header("Location: /page.php?page=login");
}
?>
<!DOCTYPE Html>
<html>
<head>
<!--Connections made and head included-->
<?php require_once("../INC/head.php"); ?>
<?php require_once("../Scripts/DB/connect.php"); ?>
<!--Asynchronously Return User Names-->
<script>
$(document).ready(function(){
function search(){
        var textboxvalue = $('input[name=search]').val();
        $.ajax(
        {
            type: "GET",
            url: 'search.php',
            data: {Search: textboxvalue},
            success: function(result)
            {
                $("#results").html(result);
            }
        });
};​
</script>
</head>
<body>
<div id="header-wrapper">
<?php include_once("../INC/nav2.php"); ?>
</div>
<div id="content">
<h1 style="color: red; text-align: center;">Member Directory</h1>
<form onsubmit="search()">
         <label for="search">Search for User:</label>
<input type="text" size="70px" id="search" name="search">
</form>
         <a href="index.php?do=">Show All Users</a>|<a href="index.php?do=ONLINE">Show All Online Users</a>
<div id="results">
<!--Results will be returned HERE!-->
</div>

 

search.php 

<?php
//testing if data is sent ok
echo "<h1>Hello</h1><br>" . $_GET['search'];
?>

This is the link I get after sending foo. 

 

http://www.family-line.dx.am/Community/index.php?&search=foo

 

Is that mean it was sent, but I'm not processing it correctly? I'm new to the whole AJAX thing. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.