This is a migrated thread and some comments may be shown as answers.

kendo mobile json data calling problem

1 Answer 87 Views
Application
This is a migrated thread and some comments may be shown as answers.
Sajid
Top achievements
Rank 1
Sajid asked on 16 Apr 2012, 07:13 AM
Hi,
 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 webserver and called in javascript it showing eeror 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 
                       
                        dataType: "json",
                        data: { 
                            q: "javascript"
                        }
                    }
                },

first url data is geting in localhost and works great, second url is not working(but data showing  if we run the url in a browser)

it show Error

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

1 Answer, 1 is accepted

Sort by
0
Johan
Top achievements
Rank 1
answered on 08 May 2012, 09:07 AM
This is due to the basic security restrictions in browsers.
With JSON you can only use the "only phone home" principle.
If your JSON service is e.g. http://mysite.com/customers then your mobile app must be on the same domain e.g. http://mysite.com/mymobileapp/index.html.

See Additional notes on jQuery.ajax()

Johan
Tags
Application
Asked by
Sajid
Top achievements
Rank 1
Answers by
Johan
Top achievements
Rank 1
Share this question
or