Hello, I have the following XML Document:
<result>
<flag>No</flag>
<message>User Name Should Contain No Numbers</message>
</result>
After an AJAX call, I receive the response using the responseXML
object and I use the $( ) function to extend it:
Xml = $( responseObject.responseXML.documentElement );
When I try to walk the DOM using the Element.down( ) function, or any
walking function, I get no results:
Xml.down( ); -->Nothing
Xml.next( ); --> Nothing
Mozilla is not displaying an error in its error console so I have no
idea what is going on?
Further more, using traditional DOM walking techniques like so:
alert( Xml.childNodes[ 1 ].nodeValue );
The child node at index 1 above is <flag>, so its nodeValue is suppose
to be ''No'', supposedly the alert box should display so.
It displays ''null''! Could this in any way be related to why
the
Element.down( ) function is not working?
Any help is appreciated, I have been up since yesterday trying to
figure this annoying this out!
Full code is below; the CheckUserName( ) function is called on a
''onblur'' event:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* AJAX onSuccess Response Callback.
*
* @return void
*/
function _CheckUserName( responseObject )
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define Function Variables.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Validation Error Message.
*
* @var string
*/
var errorMessage = '''';
/**
* For Loop Counter.
*
* @var int
*/
var i = 0;
/**
* Validation Status Flag.
*
* @var string
*/
var isValid = '''';
/**
* XML Returned By Response Object.
*/
Xml = $( responseObject.responseXML.documentElement );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
alert( Xml.childNodes[ 1 ].nodeValue );
}
/**
* Check User Name Using AJAX.
*
* @return void
*/
function CheckUserName( )
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define Function Variables.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
userName = new String( $( ''UserName'' ).getValue(
).replace( '' '' ,
''_'' ) );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Execute AJAX Request.
new Ajax.Request( _APPLICATIONDIRECTORY +
''/User/CheckUserName'' ,
{
// AJAX Request Method.
method: ''get'' ,
// AJAX onSuccess Response.
onSuccess: _CheckUserName
} );
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---