How can I use Wicket.Ajax.Request to post a json string to a
DefaultAjaxBehaviour?

On the Javascript side I basically did something like this: 

function setupSend(xhr) {
    xhr.setRequestHeader("Wicket-Ajax", "true");
    if (typeof(Wicket.Focus.lastFocusId) != "undefined" &&
Wicket.Focus.lastFocusId != "" && Wicket.Focus.lastFocusId != null)
        xhr.setRequestHeader("Wicket-FocusedElementId",
Wicket.Focus.lastFocusId);                
    xhr.setRequestHeader("Accept", "text/xml");
  };
  
  function success(data) {
    var xml = data;
    if (typeof xml == "string") {
      xml = new ActiveXObject("Microsoft.XMLDOM");
      xml.async = false;
      xml.loadXML(data);
    }
    (new Wicket.Ajax.Call("${feedbackURL}")).loadedCallback(xml);
  };
  
  function call(data, revertFunc) {
    $.ajax({
      url : "${feedbackURL}", type: 'POST', contentType:
'application/json;charset=UTF-8'
     ,dataType: (($.browser.msie) ? "text" : "xml"), data :
$.toJSON(data)
     ,beforeSend : setupSend ,success : success, error : revertFunc
    });
  };


to do something similar to what Wicket.Ajax.Request.post does, except I
change the contentType to 'application/json'


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to