In my localhost, I create an web application to get data from website, it just contain one character. So I create this:
$.get("http://www.website.web.id/data.txt", function(client_req) {
alert(client_req);
});
But it can't load the data. Why?
In my localhost, I create an web application to get data from website, it just contain one character. So I create this:
$.get("http://www.website.web.id/data.txt", function(client_req) {
alert(client_req);
});
But it can't load the data. Why?
Yes, cross domain issue, you can use JSONP or CORS to overcome this issue, I have posted multiple times on this:
JQuery JSON Calls To PHP WebService Always Runs "Error" Callback
Is there any physical, readable difference between a JSON string and a JSONP string?
This may be a solution for you. See:
I'd advise using JSON for this though -- I know it may not sound like a quick and easy solution, but it's the best solution.
If you're using PHP, you could do something like this:
<?php
$arr = array('example' => 'example data', 'anotherexample' => 'OK', 'userage' => 13);
echo json_encode($arr);
?>
That'd get it to output the data in JSON. Then in your jQuery, you'd do something like:
$.getJSON('http://www.website.web.id/data.php', function(client_req) {
alert(client_req.example);
alert(client_req.anotherexample);
alert(client_req.userage);
}
});
Hope that puts you in the right direction.