facebook

error trapping for a JSON web service call – not working

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #323662 Reply

    JohnWord
    Member

    I’m trying to put some error trapping around a web service call which is not working.

    example code from a function in the .._custom.js file:
    var url = “http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=”
    + stock;

    $.getJSON( url, function( data ){

    //extract the results from json query results
    resultXML = data.query.results.string;

    //parse XML result
    parser = new DOMParser();
    doc = parser.parseFromString(resultXML, “text/xml”);
    $xml = $(doc);
    $result = $xml.find(‘GetQuoteResult’);
    code = $result.attr(‘code’);

    if (code == 200) { //success

    alert(‘answer: ‘ + result);
    $(‘#m1-GetStock-Answer’).text(result);

    } else {
    // failed
    alert(‘Error: did not work’);
    }

    })
    .success(function() { alert(“success”); })
    .error(function() { alert(“error”); })
    .complete(function() { alert(“complete”); });

    but I get a runtime error of:
    TypeError: Result of expression near ‘….success(function() { alert(…’ [undefined] is not a function on the ‘.success’ line

    thoughts?

    thanks..

Viewing 1 post (of 1 total)
Reply To: error trapping for a JSON web service call – not working

You must be logged in to post in the forum log in