I am intending to create a small api, that will do some php functions, but can be implemented by js only.
I want to create a similar solution to the facebook sdk.
So I created a php file named rest.php
and a js file nammed conjs.js now I need to perform an ajax request from the conjs.js file, but I get an undefined when trying to request an ajax request.
1) How should I build this?
2) What am I doing wrong?
rest.php
<?php
echo "Hello from ".$_GET['name'];
?>
conjs.js --> included on the html page of client (similar to
connect.facebook.net/en_US/all.js off facebook)
function getDev(){
$.ajax({
url: 'http://mydomain/rest.php',
type: 'GET',
data: 'Name=John', // or $('#myform').serializeArray()
success: function(data) { return('Get completed '+data); }
});
}
Client smaple html page: -not on domain-
<html><head> <script src="http://mydomain/conjs.js"></script></head><body>
<script>
alert(getDev());
</script>
</body></html>
Thanks in advance :)