Forum Discussion

jonathancrow's avatar
13 years ago

How to redirect the response from a REST API Call

So close...   Ok I have a form that posts the content of a textarea to the body of a specific article. The problem is that after submitting the form, the browser displays the XML response from the ...
  • xorrkaz's avatar
    xorrkaz
    13 years ago

    Try this:

     

    <@liaAddScript>
    function handleSubmit(form) {
      ;(function($) {
        $.ajax({
          type: "POST",
          url: "${my_community}/restapi/vc/messages/id/${my_topic_id}/reply",
          data ({
            "message.body":form['message.body'].value,
            "message.subject":"${the_topic}"
          })
        });
      })(LITHIUM.jQuery);
    
      // note: my_url is a Javascript variable
      // use ${my_url} if your variable is in Freemarker
      window.location.href = my_url;
    }
    </@liaAddScript>