Development discussions around Shopify APIs
He guys,
i am facing another issue while developing a public app.
I am using javascript with ajax post and get requests to my server.
I am using an ajax request to one of my php files to check status of my app into a database.
6 out of 10 times, i get file not found on that specific file, or missing icon, missing pictures or other files that 4 out of 10 work fine.
I am using Shopify's proxy
I haven't had this issue before but recently my app works 4 out of 10 browser refreshes.
Hey @WMD.
I'm hoping I can get some clarification to better help you out:
From where exactly are you making the ajax request? The view rendered through the app proxy?
Is the PHP file the backend of the same app?
Does doing this outside of an app proxy context work just fine 10 out of 10 times?
Can you show front end code I could use to replicate on perhaps a non-PHP app?
Cheers.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi Alex,
I will answer question by question below.
The ajax requests are made to a php file found on my app's folder using shopify's proxy
Yes, the php file is a part of the same app.
I am not sure what do you mean. The request it is a simple request for the state of a value into my db, using plain javascript.
My Javascript function is as below
function getAjax(url, success) { var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP'); xhr.open('GET', url); xhr.onreadystatechange = function() { if (xhr.readyState>3 && xhr.status==200) success(xhr.responseText); }; xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.send(); return xhr; }
getAjax('http://' + hostname + '/apps/myapp/checkapp.php?p1=1&p2=2', function(data){ console.log(data); });
Please note that the hostname a variable containing store's url.
Every time I got the error, I checked the link for that file and it is accessible 100% every time.
Please let me know if I missed anything.
Thank you
Right.
I have done some more tests now and it looks like the Proxy does not points towards the files that are coming back as not found.
After a few refreshes, the file is found and works as intended.
It is not just PHP files, it's images and icons too.
Thanks for the extra info.
Can you clarify for me what you mean by the Proxy does not points towards the files that are coming back as not found? Where is the proxy pointing to instead if it isn't pointing to your files? Also, would you mind sharing your app's numeric ID? You can find that on the end of the URL in your partners dashboard when viewing it directly.
Cheers.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi again Alex,
Here's the number you requested 2809547
Please let me know if I am doing something wrong.
Thanks
How consistently are you able to replicate this? On my end, I have not been able to replicate. Is your server receiving these requests if you can see in your logs? This seems like a strange one for sure. Form what I can tell, you're not doing anything specifically incorrectly.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
User | RANK |
---|---|
54 | |
11 | |
5 | |
5 | |
4 |
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023