(XMLHttpRequest) and AppGini

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
labib saleh
Posts: 23
Joined: 2014-12-29 21:46

(XMLHttpRequest) and AppGini

Post by labib saleh » 2017-03-03 09:45

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 3160 times
Is there a conflict between XMLHttpRequest() and AppGini codes? and how can I fix this problem please?

Thank You

User avatar
a.gneady
Site Admin
Posts: 1354
Joined: 2012-09-27 14:46
Contact:

Re: (XMLHttpRequest) and AppGini

Post by a.gneady » 2017-03-07 05:48

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.
:idea: AppGini plugins to add more power to your apps:

labib saleh
Posts: 23
Joined: 2014-12-29 21:46

Re: (XMLHttpRequest) and AppGini

Post by labib saleh » 2017-03-11 10:44

Thanks Ahmad, that helped

Post Reply