I have written a code for taking JSON data from a PHP and putting to listview, it works great in localhost.
When I put the PHP file in a web server and called in Javascript it showing error and not getting data.
This method I have used:
var dataSource = new kendo.data.DataSource({
transport: {
read: {
//url: "userchk.php", //this works in localhost
url: "http://example.com/web/userchk.php", this is not working in localhost
dataType: "json", // JSONP (JSON with padding) is required for cross-domain AJAX
data: { //additional parameters sent to the remote service
q: "javascript"
}
}
},
The first url data is getting in localhost and works great, second url is not working(but data show if we run the url in a browser).
It show an error like this:
XMLHttpRequest cannot load http://example.com/web/userchk.php?q=javascript. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
waiting for a good response
This may be due to cross domain issue. You need to use datatype:jsonp .. A sample code reading data from ODATA Version 2.0 feed is as following ,
You can read the complete “Kendo UI ListView Control and OData in Windows Phone Application” post.
Thanks
@debug_mode