I am new to Jquery, I am trying to post some data to cross domain and I want to handle the response which is a complete HTML page
I am using the following code
$.ajax({
url: "http://www.somehost.com/abc/xyz.php",
type: "post",
data:{page: "123", calltype: "1"},
// crossDomain: true, I tried with using it as well
dataType:'html',
success: function(response, textStatus, jqXHR){
console.log(response);
},
error: function(jqXHR, textStatus, errorThrown){
console.log("The following error occured: "+textStatus);
console.log(jqXHR);
},
});
When I use dataType:'html'
, error
function fired and firebug log with
POST http://www.somehost.com/abc/xyz.php 302 Moved Temporarily 231ms
The following error occured: error
Object { readyState=0, status=0, statusText="error"}
but when I use dataType:'jsonp'
, again error
function fired but this time HTML response loaded successfully but there is some parse error which I am not able to understand and firebug log with
FIRE BUG
The following error occured: parsererror
Object { readyState=4, status=200, statusText="success"}
SyntaxError: syntax error
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E
and html response is correct(because I clicked on the link in firebug it is openning) which is something like this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<title>Welcome</title>
.
.
.
I want to do some work on this html page response, I dont know what I am doing wrong please help me.
Edit
After checking @alkis reply, I am trying to use this proxy page on my localhost right now, the server which I am requesting requires some kind of login, which work fines when I call cross domain ajax call (which loads the page fine but there is some kind of parse error I mentioned above), but I dont know it is not responding the exact same page when I use proxy, any help ?