$.ajax not working right

I have a registerpage,a emailvalipge,indexpage, I want to check the existence of the email account.
It worked fine before. But it’s not working now. I suspect the $.ajax part.

1.the registerpage code:

$(document).ready(function() {
	type: 'GET',
	datatype: 'json',
	url: "emailvali.php",
	success: function(data) {
	   var tmp=document.getElementById("email").value;	
	   var dataArr = eval(data);
var count=0;
for (var i=0; i<dataArr.length; i++)
	if (dataArr[i] == tmp)
  if (count==1)
	  $("#marker").html("email exists."); 
	  document.getElementById("check").value = 2;
	  document.getElementById("check").value = 1;
	error: function() {
		alert("json reload fail");

<input type="text" name="email" id="email">
<span id="marker"></span>
  1. emailvalipage code:
error_reporting(E_ALL & ~E_NOTICE);

include $_SERVER['DOCUMENT_ROOT'] . '/includes/db2.inc.php';
		$result = $pdo->query('SELECT email FROM users');
	catch (PDOException $e)
		$error = 'error fetching email.';
		include 'error.html.php';
	foreach ($result as $row)
		$emails = array($row['email']);		
	echo json_encode($emails);	

before, When I typed in a exist email account, at the part it shows “email exists”. now it shows nothing, I test the count value, it’s always gonna be 0. The database part,sql part should be correct.
Does anyone know what’s the possible error?

I suspect nothing is being sent in the ajax request, seems to be missing the data param,

data: { id: id, val: $(id).val(), id2: id2, val2: $(id2).val(), action: 'ajax'

It’s because the target emial account does not exist. Thank you though.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.