Page 1 of 1

(XMLHttpRequest) and AppGini

Posted: 2017-03-03 09:45
by labib saleh
I'm using an external PHP file in my AppGini project, and I'm using AppGini header and lib files in that file for sure to get the same theme and access to MySQL.

The file works fine when not using AppGini header codes, but when I add them I face a problem! Digging through the code, I found the following:
This PHP file uses a javascript function to check the success of it, using the following code:

Code: Select all

	var xhttp = new XMLHttpRequest();
	xhttp.onreadystatechange = function() {
		if (xhttp.readyState == 4 && xhttp.status == 200) {
			if(xhttp.responseText == "1")
			{
				//success, implement next code
			} else {
				//failed
				alert("ERROR , couldn't save this") ;
			}
		}
When not using AppGini this part (xhttp.responseText) returns "1" so everything works good, but when using it I don't get "1" for that, instead I get html contenet or so as shown in this image.
Capture.png
Capture.png (50.84 KiB) Viewed 3163 times
Is there a conflict between XMLHttpRequest() and AppGini codes? and how can I fix this problem please?

Thank You

Re: (XMLHttpRequest) and AppGini

Posted: 2017-03-07 05:48
by a.gneady
You should not include the header.php and footer.php in your ajax script as they are usable only for full pages rather than ajax responses.

Re: (XMLHttpRequest) and AppGini

Posted: 2017-03-11 10:44
by labib saleh
Thanks Ahmad, that helped