jquery - how to know whether php file handling the ajax request or not -


i've code snippet ajax request:

<script type="text/javascript">         $(document).ready(function() {             $('#temp').click(function() {                 var username = $('#un').val();                 $.ajax({                     url: "inter.php",                     data: 'user=' + username,                     cache: false,                     type: 'get',                     success: function(data, textstatus, jqxhr) {                         if (! data.length === 0) {                              $('#msg').append('available');                             $('#sub').removeattr('disabled');                         } else {                              $('#msg').append("username not available");                             $('#sub').attr('disabled', 'true');                         }                     }                 });             });         });     </script> 

and code in inter.php

<?php  $arr = array('one', 'two', 'three'); if (in_array($_get['user'], $arr)) {     echo "username available"; } else {     //echo "0"; } ?> 

but, every time i'm getting message username not available.
can help? i'm newbie ajax.

edit
$_get['user']
same problem remains.

the problem:

data: 'user=' + username, $_get['un'] 

you're not using same parameter-name "user name" or whatever. in js you're calling "user", in php you're looking "un".


Comments