Assuming that contents of file response.php contains only:
<?PHP die('RESULT'); How do I get that response captured in dhtmlajax so I can process the forms based on the resposne?Please take a look at the sample dhtmlxAjax/samples/01_samples_of_usage/01_send_request.html Here process.php generates xml response. Therefore, outputResponse method parses loader.xmlDoc.responseXML. If you are going text response, you need to get responseText.
Ahhhh… I don’t know how many times I looked at that. Thanks.
Another question. I am using LightAlert.js for a skinnable alert box. Are there some clues in the script somewhere where I can look at to figure out how to skin that alert box that opens up?
Clarification: What I mean, is I am looking for a more dynamic replacement for LightAlert.js which is not supported and has not been updated since 2008. Is there a replacement in the DHTMLX family of products?
I don’t have a clue what to do looking at your examples when I am trying to get text responses back. Your documentation is also lacking any good examples for non-XML uses.
How do I change the below to get it to bring back the text response:
function outputResponse(loader){
if(loader.xmlDoc.responseText!=null)
alert("We Got Response\n\n"+loader.doSerialization())
else
alert("Response contains no XML")
}
I finally gave up and wrote my own ajax script to grab the text response. My recommendation is this script be updated because it does not work with text responses and no documentation is available to show how to edit the script to make it happen. This appears to have potential, but I seriously recommend updating the documentation. If you want to get people to buy the premium licenses and they see the responses in this forum, it may give them second thoughts. I am still debating on buying the license for the dhtmlx products because they have a lot of potential but before I invest, I want to know the support is there and things work and documentation is there I need.
Here an example of what I finally came up with after a hint in one of the other forum groups here:
function sendRequest(){
var url = setURL();
var loader = dhtmlxAjax.getSync(url);
var response = loader.xmlDoc.responseText;
alert(response);
}
function setURL(){
var seturl = "process/process.user-message.php?"+encodeURI(getFormValues());
return seturl;
}
function getFormValues(){
var strparams;
var strsendtype = document.getElementById("sendtype").value;
var strsubject = escape(document.getElementById("subject").value);
var strsubject = escape(document.getElementById("message").value);
strparams = 'sendtype='+strsendtype+'&subject='+strsubject+'&message='+strsubject+'&uid='+<?=$user_id;?>;
return strparams;
}
function strtrim(str) {
return str.replace(/^\s+|\s+$/g,"");
}
This is my actual implementation of dhtmlxAjax and once I got it to work, I like it a whole lot more than the old style jquery I used to write into each form page.
Variable response can be used to capture the return from the process file and write to a div or make a certain form field have focus. This was specifically what I was looking for and was not being returned following what I had received propr to a few days ago. The above example works with the GET method. A key hint though for those who use this, don’t assign a method to the form. Just omit that parameter. For the submit button I have added onclick=‘sendRequest’. For now if the process file does not return “OK”, I have it generating the standard alert modified with LightAlert.js and then if I need a success message I can do that.