I'm using page method to retrieve login information. My code goes as follows,
$.ajax( {
type: "POST",
url: Main.url + loginBox.url ,
data: '{"jsonrpc": "2.0", "method": "login", "params": {"login": "'+nameVal+'", "pass": "'+passVal+'"'+ ( loginBox.userSaveUdid ? ","id": 1}',
async: true,
dataType: "json",
contentType: "application/json",
beforeSend: function(){
alert("-------------------------------------------------------------------------------------loginBox.submit : beforeSend");
$("#login-error").html();
Loading.show();
},
success: function(data) {
alert("-------------------------------------------------------------------------------------loginBox.submit : success = ");
if( data.error ){
$("#login-error").html(data.error.message)
}else{
loginBox.LogInSuccess(nameVal,data.result.user_id,data.result.token)
/*
loginBox.userName = nameVal;
loginBox.userLogged = data.result.user_id;
loginBox.userToken = data.result.token;
Limit.getLimit();
loginBox.hide();
*/
}
},
complete: function(){
alert("-------------------------------------------------------------------------------------loginBox.submit : complete");
Loading.hide();
},
error: function(XMLHttpRequest, textStatus, errorThrown){
$("#login-error").html(textStatus)
alert("-------------------------------------------------------------------------------------loginBox.submit : error " +textStatus);
}
});
I'm getting 404 Not page found error. I used firebug to check those and request and responses.
this what i got.
Response Headersview
Via 1.1 BILEETAISA
Connection Keep-Alive
Proxy-Connection Keep-Alive
Content-Length 728
Date Wed, 27 Jul 2011 22:17:53 GMT
Content-Type text/html; charset=UTF-8
Server Apache/2.2.3 (CentOS)
X-Powered-By Phusion Passenger (mod_rails/mod_rack) 3.0.7
X-Runtime 0.004490
Status 404
Request Headersview
Host xxxx.tv
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Proxy-Connection keep-alive
Origin null
Access-Control-Request-Me... POST
Access-Control-Request-He... content-type
Pragma no-cache
Cache-Control no-cache
Can someone tell me where is the fault. Is it should be accept field in request header as application/json? Should i add to json library to my project also? Isn't that enough with only jquery. Pardon me if this is dumb question. I'm newer to this stuffs.