Hello Good day everyone, anyone can help me with error " Undefined index: is_ajax"

I've encountered it. Im new in AJAX and im trying to use it on my login page.

This is the code for my main.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.latest.min.js" > </script>
<script type="text/javascript">
$(document).ready(function() {

	$("#login").click(function() {

		var action = $("#form1").attr('action');
		var form_data = {
			username: $("#username").val(),
			password: $("#password").val(),
			is_ajax: 1

			type: "POST",
			url: action,
			data: form_data,
			success: function(response)
				if(response == 'success')
					$("#form1").slideUp('slow', function() {
						$("#message").html("<p class='success'>You have logged in successfully!</p>");
					$("#message").html("<p class='error'>Invalid username and/or password.</p>");

		return false;



<div id="content">
  <h1>Login Form</h1>
  <form id="form1" name="form1" action="doLogin.php" method="post">
      <label for="username">Username: </label>
      <input type="text" name="username" id="username" />
      <label for="password">Password: </label>
      <input type="password" name="password" id="password" />
      <input type="submit" id="login" name="login" />
    <div id="message"></div>

and this is my code in doLogin.php


	$is_ajax = $_REQUEST['is_ajax'];
	if(isset($is_ajax) && $is_ajax)
		$username = $_REQUEST['username'];
		$password = $_REQUEST['password'];

		if($username == 'demo' && $password == 'demo')
			echo "success";


My error is on doLogin.php. The Line 3.

$is_ajax = $_REQUEST['is_ajax'];

Anyone can help me? Thanks a lot

5 Years
Discussion Span
Last Post by jstfsklh211

is_ajax is not being sent from your form
so $_REQUEST is undefined
where is $_REQUEST coming from
also to prevent errors like that

$is_ajax = $_REQUEST['is_ajax'];
if(isset($is_ajax) && $is_ajax) {

should be

if(isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax']) {
$is_ajax = $_REQUEST['is_ajax'];
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.