Это мой скрипт jquery:
<script>
$(document).ready(function(){
$("#username").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("check.php",{ user_name:$(this).val() } ,function(data)
{
if(data=='no') //if username not avaiable
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);
});
}
else
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);
});
}
});
});
});
</script>
Это мой скрипт php:
<?php
header("Content-Type: text/plain");
$username=$_POST["user_name"];
$xml = simplexml_load_file("usernames.xml");
foreach($xml->children() as $child)
{
if ( $child == $username ) {
echo "no";
}
}
?>
А это мой xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<usernames>
<num>bobby</num>
<num>murali</num>
<num>rakesh</num>
<num>manoj</num>
</usernames>
Я неЯ понимаю, что проблема заключается в том, что проблема заключается в том, что проблема заключается в том, что проблема возникает. Я думаю, что php вызывается и выдает правильное утверждение.цикл и входит в else в моем скрипте jquery. Я выполнил php индивидуально, и он работает нормально. Я думаю, что проблема в скрипте jquery. Мой скрипт работает нормально, когда я подключаюсь к базе данных и проверяю наличие имени пользователя.