08-31-2007, 12:04 AM
In response to an Ajax call, there could be two kinds of retuns:
1)For the responseText, what is the differences as compared to the responseXML?
2)For what purposes should return responseText not responseXML, or vice versa?
3)For DOMString responseText, can I use the getElementById, documentElement functions?
08-31-2007, 12:50 AM
responseText returns a string, and it is just a string. If you need to parse data from it, it can only be done with string handling methods.
responseText is good if you're okay with using innerHTML, which as of so far is not standards compliant. You can just set the innerHTML of an object to the returned responseText and it will appear in the document.
responseXML returns an XML doc, that can be accessed and parsed using normal DOM methods.
You have more control over the data using xml, while using the string it is easier to retrieve bits of html that can be displayed as a whole.
Does that answer your question?
I'm going to go ahead and move this to the ajax discussion section.
09-14-2007, 11:30 PM
I use the text method. The first characters are a confirmation of which PHP is returning. This is stripped away. I then divide up the records with split() with a special character "^". The individual records are divided into their variables using another Split() then the values are put into a string of HTML code which is then moved the screen using the innerHTML method.
// RETURN OF LIST AND THEN SEND TO SCREEN
if(responseresult.search(/php response: harvest_list_harvesters.php/)>-1)
var list_results = responseresult.replace(/php response: harvest_list_harvesters.php/,"")
var list_SplitResult = list_results.split("^");
var output_list = "";
//note: the length is subtracted by 1 because the split adds an extra record to the array at the end
var record_key = "";
var record_firstname = "";
var record_lastname = "";
var record_SplitResult= new Array();
record_SplitResult = list_SplitResult[i].split("|");
record_key = record_SplitResult;
record_firstname = record_SplitResult;
record_lastname = record_SplitResult;
output_list += "<input type=\"button\" onclick=\"ajaxFunction('harvester_key=" + record_key + "','harvest_get_harvester.php');\" value=\"" + record_lastname + ", " + record_firstname + "\"/><br/>";
document.getElementById('harvesterlist').innerHTML="<b>HARVESTERLIST:<br></b>" + output_list;