jQuery Ajax help needed

Aug 13, 2014

Hi All!

In a previous post (http://community.articulate.com/forums/p/33796/182514.aspx), James Kingsley responded to Mike Amelang about how to create a survey response through Javascript. That works great!!! (Thank you James!)

However, in Mike's closing comment he asked: "Any idea why---even when the SurveyGizmo data is successfully updated---that the ajax response is always 'error'?"

I am having the same issue when trying to get the JSON response back from the SurveyGizmo server in Javascript.

If I drop the URL into the browser, I can see all of the JSON data come back. However, it always kicks back an error in Javascript: "parsererror" in textStatus and "jQuery [a bunch of numbers] was not called" in error.

I've fiddled with the code and have finally been able to get:

[Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://127.0.0.1:32767/resources/scripts/_rand_cache_15435/jquery-1.7.1.min.js :: .send :: line 4" data: no]

This is what I get from a regular ajax call:

XMLHttpRequest cannot load https://restapi.surveygizmo.com/v3/survey/1763155/surveyresponse?user:pass=XXXXXXX&_method=PUT&data[2]=9403585&data[3]=805&data[4]=true. The 'Access-Control-Allow-Origin' header has a value 'http://www.surveygizmo.com' that is not equal to the supplied origin. Origin 'http://localhost:8020' is therefore not allowed access.

Is it possible to get the JSON return info in Javascript? Has anybody ever done it with success?

Thanks in advance for any help you can provide!

********here's my code**************

function SendResponse() {

$.ajax({

url: 'https://restapi.surveygizmo.com/v3/survey/1763155/surveyresponse?user:pass=edclrmeuip@nordstrom.com:Learning&_method=PUT&data[2]=9403585&data[3]=805&data[4]=true',
type: 'GET',
crossDomain: true,
dataType: 'jsonp',

success: function() {
alert("success");
},

error: function (jqXHR, textStatus, error) {
var url = jqXHR.url;
/* replace caturl with url in your append */
$('#showdata').prepend("<font size=\"1\" color=\"red\">ERROR : '" + error + "' trying to access: " + url + "</font></br>");
alert(error);
},

done: function() {
alert("Im done");
}
});
}

Be the first to reply

This discussion is closed. You can start a new discussion or contact Articulate Support.