1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / JQuery AJAX call from ASCX not working

JQuery AJAX call from ASCX not working

4 posts, 0 answered
  1. KJ
    KJ avatar
    1 posts
    Registered:
    24 Jan 2013
    24 Jan 2013
    Link to this post

    We have created a custom ASP.NET control and it is making an AJAX call to another page using JQuery.

    Here is some part of the HTML

    <%@ Control Language="vb" CodeBehind="ReferralForm.ascx.vb" Debug="true" Inherits="MarketingReferral.ReferralForm" %>
    <script src="Scripts/jquery-1.9.0.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {        $("select[id$=drpd_PrefStaffPreson]").change(function () {
                var v = $("select[id$=drpd_PrefStaffPreson]").val();
                var t = $("select[id$=drpd_PrefStaffPreson]  option:selected").text();
                $("#<%=hidden_prefName.ClientID%>").val(t);
                    $("#<%=hidden_prefEmail.ClientID%>").val(v);
                });            $("select[id$=drpd_PrefBranch]").change(
                function () {
                    var brnch = $("select[id$=drpd_PrefBranch]").val();
                    $.ajax({
                        type: "POST",
                        url: 'ReferralHelper.aspx/GetStaff',
                        data: "{branch: '" + brnch + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (response) {

    /************** Rest Truncated ***************/

    When we run the control in sitefinity, the AJAX call fails and it gives an error message saying 'not found' (which I assume is the page ReferralHelper.aspx). We have kept the page in sitefinity web root. How can we get this working?

  2. Venkata Koppaka
    Venkata Koppaka avatar
    67 posts
    Registered:
    24 Sep 2012
    25 Jan 2013
    Link to this post
    Hello KJ Singh,

    Can you try inspecting the POST request using Firebug on firefox.? This way you could see what URL it is making the request to and can correct the URL if it is wrong.  Please also try going to the page manually through the browser to verify if the page in question in fact does exist at the URL that you are trying to access it.

    Greetings,
    Venkata Koppaka
    the Telerik team
  3. Stephen2
    Stephen2 avatar
    94 posts
    Registered:
    05 Feb 2012
    25 Jan 2013 in reply to Venkata Koppaka
    Link to this post
    url: 'ReferralHelper.aspx/GetStaff'

    Isn't that meant to have a forward slash in front, if your aspx page is in the web root? e.g.,:
    url: '/ReferralHelper.......
  4. Bonny
    Bonny avatar
    58 posts
    Registered:
    11 Nov 2016
    28 Jan 2013
    Link to this post
    Hi,

    Actually the request should begin with the protocol, followed by the path to your page.
    Example: http://localhost:81/YourPage.aspx
    This is not Sitefinity related, but more like general AJAX.
    Try to make request using full url to your page and contact us back if the problem remains.

    All the best,
    Bonny
    the Telerik team
4 posts, 0 answered