Hi,
On Wed, Oct 16, 2013 at 3:48 PM, frasese <[email protected]> wrote: > Hi all, > > I have a jquery script to comunicate with wicket via ajax. It was working > fine with wicket 1.4.17, until I've migrated to 1.5.10 version. > > Now, my AbstractAjaxBehavior it's not called anymore, and the ajax call > receives a 302 moved temporarily. > > Here is my code: > > javascript/jquery > ... > $.ajax({ > url: $('#callBackURL').html(), > This should be .text(). You cannot use HTML as URL location. > type: 'post', > cache: false, > data:id, > contentType: 'text/plain; charset=utf-8', > dataType: 'json', > success: function(json) { > alert(json); > }, > error: function (XMLHttpRequest, textStatus, errorThrown) { > alert("error :"+XMLHttpRequest.responseText); > } > }); > ... > > html/wicket-tags > ... > <label id='callBackURL' wicket:id="callBackURL" > style='display:none'></label> > ... > > java > ... > abstractAjaxBehavior = new AbstractAjaxBehavior(){ > private static final long serialVersionUID = 1L; > > @SuppressWarnings("unchecked") > public void onRequest() > { > System.out.println("ajax detected..."); > //get parameters > final RequestCycle requestCycle = RequestCycle.get(); > > WebRequest wr=(WebRequest)requestCycle.getRequest(); > > HttpServletRequest hsr = (HttpServletRequest) > wr.getContainerRequest(); > > long id = -1; > try { > BufferedReader br = hsr.getReader(); > String inputString = br.readLine(); > > try { > id = Long.valueOf(inputString); > } catch(Exception ex) { System.out.println("ERROR : > "+ex.getMessage()); > ex.printStackTrace();} > } catch (IOException ex) { > System.out.println(ex); > } > > System.out.println("creating json for "+id+"..."); > String data=createJSONData(id); > System.out.println("returning json :"+ data); > > requestCycle.scheduleRequestHandlerAfterCurrent(new > TextRequestHandler("application/json","UTF-8", data)); > } > }; > add(abstractAjaxBehavior); > String callBackURL= abstractAjaxBehavior.getCallbackUrl().toString(); > > add(new Label("callBackURL", callBackURL)); > ... > > Any clue about this??? > What is the produced URL ? Check with Firebug/Dev tools what is the requested url and what is the difference with the real one. Usually response with status 302 has a header 'Location' pointing to the new url. > > Regards > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-AbstractAjaxBehavior-302-moved-temporarily-tp4661838.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
