AJAX not working with URL rewritten page

Splash Forums Rewrite Users AJAX not working with URL rewritten page

This topic contains 3 replies, has 3 voices, and was last updated by  Christian Kaltepoth 8 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #25237


    Hi all,

    I’m trying to call jQuery’s AJAX method in my jsp page(“abcd.jsp”) to load some content into a DIV on a Button click.

    I’ve a JSP (“new.jsp”), its URL is mapped to a Servlet(“myservlet.java”) using URL Rewrite.This servlet forwards the request to “abcd.jsp”. Now when the user clicks on the Button in “abcd,jsp”, the click() method gets called but the AJAX method doesn’t work.Both $.get(“myservlet”) & $.post(“myservlet”) fail.

    When I remove the URl Rewrite rule, then everything works fine..
    Also, when I run this “abcd.jsp” page directly, eveything works OK.Both these method works and displays content send by servlet..

    Does these AJAX get & post methods deal with the URL of the page ??
    or, Am I doing something wrong ??

    Thanks in advance.


    Could you paste a dump of the network traffic when attempting to do your AJAX request? (Via your browser’s network traffic inspection tab) Thanks.




    Hello Lincoln Sir,

    I have attahced the Network Traffic Shot picture with this comment.

    I searched on the internet and found that this is common problem of AJAX not working with URL rewrite.

    In case of Microsoft IIS people found the sol’n to be:

    “you can not create the url rewrite on the root directory and that you must have a directory between in order for ajax to continue working. ”

    url rewrite to: http://www.bandsUK.com/U2 will break all ajax
    url rewrite to: http://www.bandsUK.com/bands/U2 will keep ajax working.

    So does this apply to our rewrite too ???
    And if yes then how ???



    The problem is that you are getting a 404 when sending the request to your server. So I guess the URL is not correct.

    Is /TechTalk/newjsp/newserv the correct URL? Please note that if you rewrite the URL of your JSP and then use relative URLs for the AJAX request you may run into problems.

    I recommend to use absolute URLs instead. So instead of:


    You should use:


Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.