I have the following extremely basic $.ajax function:
function doAjax(url, args){
var retVal = $.ajax({
type: "GET",
url: url,
data: args,
async: false
}).responseText;
return retVal;
}
When processed, the returned data from the url should be some text, like “Invalid User credentials”.
What is actually being returned by retVal some preformatted HTML, specifically:
<html>
<body>
<h1>SRV Server:</h1><br> Document Contains no data.
</body>
</html>
I am not understanding why. Can anyone explain what is going on with this script?
The server side code is accepting and processing the data correctly. This is the code that the $.ajax calls, it validates the args and processes the data accordingly.
The return from the ‘$retval = $fvAPI->responseCurl[‘ERROR’];’ statement is: “Invalid User credentials”.
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/freightView.inc.php';
$id = 0;
$fv = 0;
$status = 0;
$retval = null;
if(isset($_GET['id'])){
$id=$_GET['id'];
if(is_numeric($id)){
if(isset($_GET['fv']) && strlen($_GET['fv'])>3){
$fv1 = substr($_GET['fv'],4,1);
if(is_numeric($fv1)&& $fv1>0){
$fv=$fv1;
$status=1;
}
else $status = 0;
}
else $status = 0;
}
else $status = 0;
}
else $status = 0;
if($status==1){
$fvAPI = new fv($id);
switch ($fv){
case 1:
if($fvAPI->postEditXML()){
$retval = $fvAPI->responseCurl['ERROR'];
}
break;
case 2:
break;
case 3:
break;
case 4:
break;
defaut:
break;
}
}
return $retval;
The jquery is working but the server is returning an error for that request. If you put the url into a browser you will see the same result.
You need to identify why the server is responding with an error.