PHP web service not working from jQuery AJAX

后端 未结 2 409
轮回少年
轮回少年 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: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?

提交回复
热议问题