AJAX not working in android/ios


#1

My website URL is http://logomatlookup.epizy.com/.

I’m an hourly production employee at a company and I thought that (in my off time) I might make an electronic lookup system for some of our inventory to learn more programming as an exercise. I don’t know if this matters or not, but this is not official or sanctioned by the company. This is my own personal project (though I am using real data from my employer).

In any case, my small little web app seems to work perfectly well on desktop. It also works perfectly well when I access it from android/ios from my apache server hosted on my computer on my local network.

However, when I upload it to infinity free, it still works on desktop no problem, but on android/ios (both in chrome and in firefox), there is a failure to receive actual json data from my logo_request.php file that is supposed to return the data requested so that the javascript can insert it into the webpage. Using Chrome’s remote debugging tool the xmlhttprequest returned from logo_request.php seems to be something like an Nginx 444 .

It does, however work, when I directly access logo_request.php in chrome/firefox, and then subsequently use the main page for searches.

I’ve seen that infinityfree has some security issues with AJAX and validating that only webbrowsers can access the sites, but given that I can get it to work, it doesn’t seem like that’s actually the issue.

Does anyone have any idea why this isn’t working, or what could be the cause? Again, this problem ONLY exists on android/ios. I have not been able to replicate it on desktop.


#2

P.S. I really don’t think the code is the problem, but feel free to take a look at my javascript code in the main page which is displayReults.js.

If you need the php code from logo_request.php I will happily post it if it will help solve this issue.


#3

You can’t do AJAX requests on your device on free hosting, even with a free subdomain, because there is a security system that prohibits that. You may need to add the domain on Cloudflare, but you can’t do that because you’re using a subdomain. The only solution is to upgrade to premium hosting or to go elsewhere to host your AJAX requests website.


#5

Can you explain why the AJAX works on desktop then? Can you explain why the AJAX works when I first access logo_request.php prior to using the search on android/ios.

Your answer is wrong. Try it. It works fine on desktop and after I’ve actually used logo_request.php without the AJAX call.

Besides. The site clearly says you can use AJAX when its your website calling it. You just cant call it from an external api:

AJAX requests from other websites. AJAX requests are only possible on the same (sub)domain.


#6

i don’t get ,that i never heard this one XD

I think that depends what system you’re using. that works on Windows fine and on Android or IOS incorrect? that we’d like to see a screen shot :slight_smile:


#7

Just to clarify: AJAX is supported. But cross domain AJAX (performing AJAX requests from other domains), or any kind of direct API access is not possible.

The short explanation: there is a security system which requires every domain name to be opened in a browser first to set a cookie, and only with that cookie you can access the website behind it.

This is also the reason why it doesn’t work initially, but does work if you open the page first.

This security system is explained in more detail here:


#8

But then why does it work on desktop platforms without a problem? (tested on both windows and linux (ubuntu, and arch)).

Why are mobile platforms having this issue of having to actually load the blank page first? I’m not understanding what the security system is doing that would A) break this functionality on mobile platforms that works on desktop and B) cause it to strangely work after a page is loaded?

I suppose I can use a workaround by just redirecting from index to logo_request then to the search page, but it just seems like there are unanswered questions here.


#9

There is a security system that prevents access to your site via other devices that don’t support JavaScript and cookies. The only solution with free subdomains is upgrade to premium hosting, where AJAX requests from other devices are supported, or get a free domain from here and add it by using ns1.byet.org and ns2.byet.org nameservers on your account. After that, enable the cPanel Cloudflare integration and click on the email that Cloudflare sent you to change the password.


#11

I know that. I’ve read it in the knowledge base and several people here have mentioned it. I’m not the one who has a difficult time reading, its you.

Just fyi for anyone, the work around of redirecting to load the logo_request.php file from index.html and then from logo_request.php (if no search parameters are present in the get request) to the new search page (logos.html, previously index.html) did work on mobile platforms.

It works just fine now even if a bit inelegant.


#12

I can’t explain that. The security system works the same on all devices and browsers, so I don’t know why it would work any differently on mobile than it does on desktop.

I tested http://logomatlookup.epizy.com/logos.html both on my desktop and my phone, and didn’t see any notable difference in the output.

If you still get this error, can you please describe what exactly is returned by the server? Did you really get a status code 444, or did you see something else?


#13

Yes, I do believe that I got the 444 status code in the http header when the javascript was requesting the json from logo_request.php. However, I unfortunately did not save the complete response so I am going off of memory. I could be wrong about the last two digits, but it was definitely in the 400 “client error” family of http response codes.

In anycase, I’m glad that it was working for you, but I am wondering if it was working because you used my workaround (which is to redirect the browser through logo_request.php then to logos.html, as after the browser has actually visited logo_request.php it seems that it works without any problem on mobile browsers).

I’m going to set up an identical copy of these pages that does not route through the php script to aid debugging. I’ll post that url and my findings shortly. I’m more than happy to do anything to help solve bugs for this service as you are helping me tremendously by giving me a solution that doesn’t involve setting up my own server in my bedroom.


#14

So I’ve set up a “mirror” of my page as logomatlookup.epizy.com/logos_test.html (every file is identical except everything is appended by _test before the file extension).

I tried it on my phone, and there has been no issue at all so far (I will admit that it hasn’t always seemed to not work. . .)

I’ll test every so often the next few days and see if I can replicate anything.


#15

No, I just opened the logos.html on my phone directly. No workarounds were required.

My best guess is that it might have been a caching issue. But I’m not sure.