473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

AJAX can't access php from outside xampp folder

I wrote simple html file that use ajax to get response from a php file.

The php file is simply echo a string.

if the html file and the php is placed inside c:/xampp/htdocs and everything work well.

What i want is to place the html on the desktop and call the php file, it does not return anything.

i guess it is an apache, xampp confguration, can someone help me plz???
Apr 30 '12 #1
13 4997
Rabbit
12,516 Expert Mod 8TB
And why can't you put it in htdocs?
Apr 30 '12 #2
I can, and i tried it and succeed.
But when i place the html for example on the desktop or any folder outside the htdocs, ajax does not succeed in returning a response.
So it is a PHP, Apache or browswer problem? And how it can be solved.
Thank you
May 1 '12 #3
Rabbit
12,516 Expert Mod 8TB
Why would you need to solve it? Just put it in htdocs.
May 1 '12 #4
i need to call it from another computer or from a phone
May 1 '12 #5
Rabbit
12,516 Expert Mod 8TB
Call what? Call a PHP file? You put the file in htdocs and then call it from where ever you want.
May 1 '12 #6
Hey Rabbit, if you don't know the answer plz don't post a reply.
I repeat: i have an html file, that will be placed outside the htdocs folder, and inside the html an ajax functionality that call a php file inside the htdocs.

When i run the html it does not return anything.

The answer was:
you should put in ur php the following line;
header('Access-Control-Allow-Origin: *');

so again, don't post rabishh answerssss
May 1 '12 #7
Rabbit
12,516 Expert Mod 8TB
It's not that I don't know about Access-Control-Allow-Origin. It's that I was trying to point out to you that there's no need to complicate things by doing that. If you are already serving the PHP file from your server, then just serve up the HTML file as well.

There's no need to activate cross domain access. By activating cross domain access, you now give everyone access to run your PHP code from anywhere they want. Cross domain access also opens up your server to more attack vectors, reducing your overall security.

So before you accuse someone of not knowing an answer and accuse them of posting rubbish, you should do your research.
May 1 '12 #8
You was repating the same question and i answered many times that this is a scenario.

so what is your solution if not Access-Control-Allow-Origin?

In fact, i need to use html5 mobile application that retrieve data posted on the server. I have a backend that publish for example messages, i need the mobile application (html5) to retrive that data which is normally saved in db.

What do you think is the best solution for this?
May 1 '12 #9
Rabbit
12,516 Expert Mod 8TB
I kept asking the same question because you never answered the question. You kept asking, in essence, how to allow for cross domain scripting. And I was asking, in essence, why do you need to allow for cross domain scripting? The answer, as far as I can tell, is you don't need cross domain scripting at all.

The way to do this is, have your HTML 5 page and your PHP page in your htdocs. When the user wants to access your data, they type in the URL for your web server, which will serve them the HTML 5 page which will retrieve data from the PHP page. There's no need to store an individual copy of the HTML 5 page on the device that is going to access the the PHP page.
May 1 '12 #10
But, i need the application to be updated by the news without refreshing the page.
why not having a standalone application using phonegapp platform that will updated from the server just like facebook phone application.
I hope you got my point of view
May 1 '12 #11
Rabbit
12,516 Expert Mod 8TB
Refreshing the HTML page? You don't need to refresh it. You just need to load it once and then use AJAX to refresh the section you want. That's what AJAX is for, to refresh only a part of a page without refreshing the whole page.
May 1 '12 #12
I know rabbit, let me explain.
In reality all this was a testing, our purpose is to have a standalone
application for mobile (using html5 and phonegapp for crossplatform purposes) and this application gonna be updated by news posted from the server.
What is the best method to make this scenario?
May 2 '12 #13
Rabbit
12,516 Expert Mod 8TB
Well, according to the phonegap website,
Q. I want to create an application for phonegap to access externally deployed web services via AJAX. How can i resolve the issue with the cross-domain security policy of XmlHttpRequest?

A. The cross-domain security policy does not affect PhoneGap applications. Since the html files are called by webkit with the file:// protocol, the security policy does not apply.

(in Android,you may grant android.permission.INTERNET to your app by edit the AndroidManifest.xml)
May 2 '12 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Nancy Drew | last post by:
hi all i want to build a trouble ticket system. i'd like to have a component written in vbscript watch a specific mail folder for income email (something like 'troubletickets@acme.com') the...
2
by: Don Leverton | last post by:
Hi Folks, I'm experiencing a problem that seems to be unique to running Access97 on Windows XP, and seems to be worse on WinXP SP2. It appears when I'm trying to import a text file. I'm...
7
by: Ibrahim. | last post by:
Hello, How can I access a Shared Folder of the Server by using the following control. 1. I need to download files from c:\resumes folde by using the following; <asp:HyperLink...
3
by: yeshwanthhv | last post by:
Hello All, I am new to VC++.NET. Right now I am stuck up with a problem. I need to create temporary files and shd store these files in C:\Temp folder which is a system created folder. Is...
0
by: staffonline | last post by:
Hi Friends, I recently can not access our share folder on a file server. the share folder have special permissions (only some domain groups allowed, but i was a member of that group). but i...
2
by: staffonline | last post by:
Hi Friends, I recently can not access some share folder on a file server. the share folders have special permissions (only some domain groups allowed, i was a member of that group). but i...
4
by: Zeb | last post by:
Hi I'm using DirectoryInfo.Delete so that when a product is removed, all it's associated images (including the folder they sit in) are deleted. This actually seems to work fine. However, the...
0
jhardman
by: jhardman | last post by:
Could you have a look at this thread ? It appears that he can't access a shared folder when anonymous use is not permitted even though he is using log in. He is trying to get in using the...
8
by: Bhuwan Bhaskar | last post by:
Hi, Can we access database (SQL) using AJAX ? Thanks, Bhuwan
11
vikas1111
by: vikas1111 | last post by:
My site is under windows hosting, Can we install Joomla (Xampp) on windows platform.?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.