언어 설정

Menu
Sites
Language
Cannot connect to my php file

Hi,

I am developping a web application which allow me to connect to my php file (script) into the wamp server. The script test if the login and password are matching (for an authentication purpose)... My application works well when I tested it with the Simulator... but with the emulator it return this message:

 

then it shows me a second blank alert.

here is my code:

<script type="text/javascript">
    function login(){
		
		var lp = document.getElementById("loginp").value;
		var pp = document.getElementById("pwdp").value;
		
			if (lp == "" && pp=="") {
				
				return;
			}
			if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp = new XMLHttpRequest();
			}

			xmlhttp.onreadystatechange = function(){
				alert("readyState=" + xmlhttp.readyState + "\nstatus="+ xmlhttp.status);
				if (xmlhttp.readyState == 4) {
					alert (xmlhttp.responseText);
				}
			}
			xmlhttp.open("GET","http://127.0.0.1/jme/login.php?name="+lp+"&password="+pp, true);
			xmlhttp.send(true);
		

	}
</script>
</head>

<body>
		<label>Login: </label><input type="text" id="loginp"><br>
		<label>Password: </label><input type="text" id="pwdp"><br>
		<input type="button" onclick="login()" value="Enter" />
	
</body>

 

Besides, I edit the "config.xml" file:

 <access origin="http://127.0.0.1" subdomains="true"/>

 

What am I missing? Thanks in advance.

Responses

8 댓글
AVSukhov

Hello,

Localhost refers to the device on which the code is running. In your case, using emulator, - refers to emulator.

For your purpose try to use local IP

colin Rao

Hi,

As above comments, seems the root cause is the http ip address. You can try once more on the device, I think it's also failed. Try to configure your php file(or web site) to let it can be visited from other computer, and try once again. 

Vikram

Hi,

The locahost 127.0.0.1 is Loopback Address. It use to the local machine inter-process communication. So if you want to using emulator or device to test will failed.

karray gargouri

Ok, but I replaced the "127.0.0.1" with my pc local ip address... it didn't work on the emulator, and in the simulator, it shows me this message:

 

 

PS: when I put the localhost address (127.0.0.1), it works on the simulator!

karray gargouri

I solved the "permissions" issue, and it works well with the simulator, but no with the emulator even when I change the ip address on the config.xml file. is there any permissions that I should add for exemple?

colin Rao

first, make the php file be visited from anothe PC in your LAN. Maybe you need a web server and create a website on it, then push your php file into the website.

second, make sure the emulator or device can access internet, or in the same LAN with your PC.

Marco Buettner

You cannot compare Simulator with Emulator... The Emulator is an own environment (keyword -> virtual maschine) on your local maschine (I think 127.0.0.1 will be the IP of the VM) ...

More details u can find here https://developer.tizen.org/development/tools/common-tools/emulator/extended-emulator-features

Check if the wamp server AVAILABLE for other devices in the ur network if u connect to the local IP (ex: 192.168.1.2) ...

May this topic is helpful for u http://stackoverflow.com/questions/24005828/how-to-enable-local-network-users-to-access-my-wamp-sites

Seoghyun Kang

Dear karray gargouri,

 

When I connected the PHP files on the external server, there was no problem.

So I think that above comments are right.

 

Please refer it.

Thanks.