AJAX, Intel XDK not working
I just said using the XDK and I think it's a great tool. I want to use PHP files in my APP and make calls to XAMPP database.
I know I need to use jquery / AJAX to connect via PHP files.
My first step is to just make an AJAX call to work with JSON. I keep getting errors like access denied and 404 for imhost local server.
I made my PHP files in XDK, would that be fine or would I need to place them elsewhere in htdocs when working with XAMPP. My problem is I don't know what I am fixing. I thought I was targeting my Xampp url: localhost -> then the file path would do this.
I also don't know if my jquery is working correctly.
Here is my ajax / jquery / index page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>
<script>
$(document).ready(function(){
$("#btn1").click(function(e){
e.preventDefault(); // prevent the default action of the click
var fname = $("#name").val();
$.ajax({
type: "GET",
url: 'http://localhost/nearly/nearly/www/php/test.php;',
data: {fname: fname},
dataType: "jsonp",
jsonp: 'callback',
jsonpCallback: 'checkname',
success: function(msg){
msg=alert("hello");
}
});
});
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="main" class="ui-content">
<form method="get" >
<label for="name">First name:</label>
<input id="name" type="text" name="name" id="name">
<button id="btn1" type="submit">Go</button>
</form>
</div>
<div id="table"></div>
</div>
</body>
</html>
my PHP to handle is test.php:
<?php
header("Content-Type: application/json");
$fname = $_GET['firstname'];
echo $_GET['checkname'] . '(' . "{'fullname' : '".$fname."'}" . ')';
}
?>
Im not 100% on JSON above. I've rarely used this method, but it was said to be best for mobile apps.
If possible, if someone can give some advice on how to set up an XDK using Xampp mySQL and let me know if my code above returns anything to my index page so that I know it works.
Can I use php files saved in my "www" project. Can't find documentation on setting up XAMPP with the XDK. I have access to web servers, so I can put the files there if that's the only way. I literally spent 2 long nights trying to fix my problems -
Any help is appreciated. For the Xampp question, my project is saved in the htdocs of my XAMPP
source to share
It works for me. It was pretty much xampp that I have some (under expression) help thanks to @TasosAanastasiou.
To use the XDK with xampp, you need to set up a virtual server (I think this is the correct term). This includes logging into your router and forwarding ports to port 80. Application type - HTTP web server. When finished, you should be able to use the browser http: // your_ip / xammp and get the xampp home page. Note that you can now get this homepage from 127.0.0.1 (as usual) and with your your_ip. Then, in your XDK, your urls in your scripts will use http: // your_ip / xampp / path to your htdocs folder.
Or
http: // your_ip / path to folder In htdocs.
Note. I had some problems when I had to change my apache config file to use the new xampp security protocol ......
I used the answer from @TasosAanastasiou again
Now it works fine and I have xdk working with Xampp and MySQL
I'll post a link.
This is the original question he posted to the chat so no answer posted Connecting with Intel XDK, AJAX and XAMPP mySQL
This is the apache link: Error while trying to access XAMPP from the network
I was not the question Thassos directed me to. The solution was to comment on "deny from all" and add "allow from all" as above.
This error occurred after performing port forwarding. And if you are talking to xampp you are probably closing.
source to share