Data Source not returning data

4 posts, 0 answers
  1. Imran
    Imran avatar
    8 posts
    Member since:
    Oct 2013

    Posted 05 Jan Link to this post

    Hi ,

     

    I have created simple app which is having login page username & password . and also i have api which return id,name as json format.

    one more thing day before yesterday same was working properly. but wen i tried today its not working.

    every time it is error function is executing.

    please help me sovle this problem, here is my code as follow

    login:

    <div data-role="view" data-title="Home View" data-layout="main" data-model="app.home" data-show="app.home.onShow" data-after-show="app.home.afterShow">
        <div class="signin-view">
            <form>
                <ul data-role="listview" data-style="inset">
                    <li>
                        <label>Email
                            <input type="email" id="email" required autofocus>
                        </label>
                    </li>
                    <li>
                        <label>Password
                            <input type="password" id="password" required>
                        </label>
                    </li>
                </ul>
                <div class="button-group button-group-vertical">
                 
                    <a class="primary" data-role="button" id="btnlogin">click</a>
                </div>
            </form>
        </div>
       
            </form>
        </div>
        <div class="offline" align="center" style="display:none;">
            You are currently offline. Before using this app in offline mode you must initialize it while you are online
        </div>
        <!-- START_CUSTOM_CODE_homeModel -->
        <!-- Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes -->
        <!-- END_CUSTOM_CODE_homeModel -->
        <!-- START_CUSTOM_CODE_home -->
        <!-- Add custom code here. For more information about custom code, see http://docs.telerik.com/platform/screenbuilder/troubleshooting/how-to-keep-custom-code-changes -->
        <!-- END_CUSTOM_CODE_home -->
        <script type="text/javascript">
            $('#btnlogin').click(function () {
                       
                           var username = $('#email').val();
                           var password = $('#password').val();
                alert(email+","+password);
                        $.ajax({
                                url: "http://www.mivbvpn.com:8040/api/users?",
                                data: {
                                    Username: username,
                                    Password: password
                                },
                                type: "get",
                                dataType: "json",
                                success: function (data) {
                                    alert("data:");
                                },
                                error: function (xhr, data) {
                                    alert(xhr.statusText);
                                }
                        });
            });
        </script>
    </div>

  2. Tsvetina
    Admin
    Tsvetina avatar
    1874 posts

    Posted 06 Jan Link to this post

    Hi Imran,

    Without looking at the error we can't tell you what can be wrong. To start with, is it a JavaScript error from your source or an error from your API? Can you copy the error message?

    Regards,
    Tsvetina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Imran
    Imran avatar
    8 posts
    Member since:
    Oct 2013

    Posted 11 Jan in reply to Tsvetina Link to this post

    Hi Tsvetina ,

     thank you for reply, the error is what i am getting is as follow:

    XMLHttpRequest cannot load http://www.mivbvpn.com:8040/api/users. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://app.icenium.com' is therefore not allowed access. The response had HTTP status code 405.

     

  4. Tsvetina
    Admin
    Tsvetina avatar
    1874 posts

    Posted 14 Jan Link to this post

    Hello Imran,

    Can you confirm that the endpoint at http://www.mivbvpn.com:8040/api/users accepts cross-domain requests? Check this Stack Overflow thread answer for more information:

    Getting request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

    Regards,
    Tsvetina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top