Note that there are some explanatory texts on larger screens.

plurals
  1. POMy Ajax POST is coming up as an error even though I am returning 200
    primarykey
    data
    text
    <p>I am making an AJAX post to a Jersey Resource. I build an image and return it. The issue is, no matter what status I return, Ajax thinks it is an error. I can actually use the error message (via error.responseTest) and it works fine. But it is ugly. What do I return to make it a success? I have returned OK(200), Accepted(202) and Created(201). All of them give me an error message but in my Console Network tab, I get a success (green with the proper status). </p> <p>I am returning it like this:</p> <pre><code> return Response.status(Response.Status.ACCEPTED).entity(image).header('Content-Type',"image/png").build(); </code></pre> <p>My JS code: </p> <pre><code>$.ajax( Monocle.config.Sightline.jobUrl + "/sightline", { type: "POST", processData: false, data: JSON.stringify({ Lat1: Monocle.Sightline.BBOX(feature,2), Long1: Monocle.Sightline.BBOX(feature,1), Lat2: Monocle.Sightline.BBOX(feature,4), Long2: Monocle.Sightline.BBOX(feature,3), OrgLat:observerCoords[0].lat, OrgLong:observerCoords[0].lon, ObHeight: feature.attributes.observerHeight, TargHeight: feature.attributes.targetHeight, OuterRadius: feature.attributes.outerRadius, LVA: feature.attributes.lowerVertAngle, UVA: feature.attributes.upperVertAngle, sAzimuth: feature.attributes.startAzimuth, eAzimuth: feature.attributes.endAzimuth, outputType: "MAX" }), contentType: "application/json", dataType: "json", success: function( results ){ var graphic = new OpenLayers.Layer.Image( Monocle.currentWidget.name + " Destination " + featurenum, "data:image/png;base64," + results, new OpenLayers.Bounds(Monocle.Sightline.BBOX(feature,1), Monocle.Sightline.BBOX(feature,2), Monocle.Sightline.BBOX(feature,3),Monocle.Sightline.BBOX(feature,4)), new OpenLayers.Size(580, 288), { isBaseLayer: false, opacity: 0.3, displayOutsideMaxExtent: true }); feature.legionObject = graphic; graphic.relatedlayer = Monocle.currentWidget.name + " Destination " + featurenum; Monocle.Map.map.addLayer(graphic); }, error: function(errMsg) { // TODO: really handle any errors } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload