PHP web service not working from jQuery AJAX

后端 未结 2 372
轮回少年
轮回少年 2021-01-28 01:04

I have created Restful web service in jomsocial environment. It\'s on the local machine. When I test it using REST console it return\'s response.

local url formed is...<

相关标签:
2条回答
  • 2021-01-28 01:29

    When you posted more information I think I found the/a reason for your trouble. According this page the syntax of your json object is wrong. The linked page shows examples for the most common datatypes in Javascript. If you read the examples, take an eye of the position of quotation signs.

    0 讨论(0)
  • 2021-01-28 01:47

    After lot of search finally I found solution to this issue. :)

    Instead of localhost need to use 10.0.2.2 this network address coz android emulator doesn't recognize localhost refer this

    Now at least success callback is called

    ajax call is..

    $.ajax({
        type: "POST",
        url: "http://10.0.2.2:5454/kisan-06/index.php?option=com_api&format=raw&app=users&resource=login&key=dfd8a84f8cdce807ae1d30a838415ea37eaa075c",
        data: {username: 'sai.kiks2@gmail.com', password: '123456'},
        success: function(data, textStatus, jqXHR) {
            alert("in success");
        },
            error: function(jqXHR, textStatus, errorThrown){
                alert("There was an error loggin in");
            }
    });
    

    But now I am facing another problem...

    How to access data returned in success callback?

    0 讨论(0)
提交回复
热议问题