[jQuery] Get / Post questions and need help with syntax. Example included.
I want to return a cdata string from an xml document whos data is
requested using get/post using the ajax plugin. I need this data to be
handed to some specific objects and to be available to other scripts
for processing.
I am new to the JQuery thing for ajax. The code I have so far..
var usrOb = { n : null }
var tplObj = { v : null }
var rowObj = { x : null , y : null , z : null }
$(document).ready(function(){
$.getCDATA = function(parentNode) {
var node = parentNode.firstChild;
while (node.nodeType != 4) {
node = node.nextSibling;
}
return node.nodeValue;
};
alert (
$.getXML( "server/sendXML.php", function( xml ){
return $.getCDATA( xml );
})
);
});
alerts me a message "undefined"
and the javascript console tells me "Error: node has no properties"
Obviously not doing it right. The nature of the string data requires I
preserve tag data inside the string. Hence the cdata. Found the cdata
function on the mailing list.
I want to send some dynamic xml cdata that contains a complex marked
up string (the string includes some javascript syntax that I need to
hand to another script ) as well as load an object with data from the
document. For example the data might be a bit of user data ( used to
populate a user object ) as well as some returned data from a sql
query ( used to populate a data object ) and the marked up string
containing html markup and some basic js logic )
How would I do that? Even just an example that gets a single node to
one of the object vars, and if you really want to make me feel all
warm and fuzzy an example of populating a more complex object. Also,
does anyone have an example of using post instead of get with php? I
can call the script and return xml with get. Using post do I have
access to the parameters used in the $_POST global? There should be a
very basic example of the server side code somewhere in the docs. I
have looked and looked. Can't find one.
Abba Bryant
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/