Loading ...
Sorry, an error occurred while loading the content.

YUI return value asyncRequest

Expand Messages
  • chimiy_duxa
    function test(){ var q; var cObj = YAHOO.util.Connect.asyncRequest( GET , ....... , { success: function (oResponse) { var r =
    Message 1 of 2 , Dec 5, 2008
    • 0 Attachment
      function test(){
      var q;
      var cObj = YAHOO.util.Connect.asyncRequest('GET', '.......', {
      success: function (oResponse) {
      var r = YAHOO.lang.JSON.parse(oResponse.responseText);
      q = r.test;

      }
      });
      return q;
      alert(q);
      }
      How return q ?
    • Ron Savage
      ... Hi You need to put it into a HTML element. Here s a sample, using a function attached to the form s onSubmit handler: var delete_occupation_callback = {
      Message 2 of 2 , Dec 7, 2008
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "chimiy_duxa" <chimiy_duxa@...>
        wrote:
        >
        > function test(){
        > var q;
        > var cObj = YAHOO.util.Connect.asyncRequest('GET', '.......', {
        > success: function (oResponse) {
        > var r = YAHOO.lang.JSON.parse(oResponse.responseText);
        > q = r.test;
        >
        > }
        > });
        > return q;
        > alert(q);
        > }
        > How return q ?

        Hi

        You need to put it into a HTML element. Here's a sample, using a
        function attached to the form's onSubmit handler:

        var delete_occupation_callback =
        {
        success: function(o)
        {
        var e = document.getElementById("person_result");

        if (o.responseText !== undefined)
        {
        e.innerHTML = o.responseText;
        }
        else
        {
        e.innerHTML = "The server's response is incomprehensible";
        };
        },
        failure: function(o)
        {
        var e = document.getElementById("person_result");
        e.innerHTML = 'The server failed to respond';
        }
        };

        function person_occupation_onsubmit()
        {
        var x = "...";
        var s = "person_id=" + document.person_form.person_id.value +
        "&occupation_id=" + x + "&sid=" + document.person_form.sid.value;
        var r = YAHOO.util.Connect.asyncRequest('POST',
        'form_action/delete_occupation_via_person',
        delete_occupation_callback, s);

        return false;
        }

        and the element called 'person_result' can simply be:

        <div id="person_result"></div>

        and you can put this anywhere on the page.
      Your message has been successfully submitted and would be delivered to recipients shortly.