Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:59:44+00:00 2026-06-01T01:59:44+00:00

I am making an AJAX call using jQuery to an .ascx control’s method in

  • 0

I am making an AJAX call using jQuery to an .ascx control’s method in the code behind to get a list of business objects:

C# Code:

if (Request.Headers["X-OFFICIAL-REQUEST"] == "TRUE") ReturnList(Request.Params[1]);

  protected void ReturnList(string param)
  {
    Response.Write(GetBusinesses(param));
    Response.Flush();
    try {  
         Response.Close(); 
        }
    catch { }
    Response.End();
    return;
  } 

private string GetBusinesses(string classificationName)
{
    System.Web.Script.Serialization.JavaScriptSerializer jSearializer = null;
    if (!string.IsNullOrEmpty(classificationName))
    {
        dSourse = BusinessesDBService.Instance.GetLatestListingsUpdates(classificationName).ToList();
        jSearializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    }
    return jSearializer.Serialize(dSourse);

}

jQuery Code:

window.jQuery.ajax({
    type: "POST",
    async: false,
    url: location.href,
    dataType: "json",
    data: ({ 'FUNCTION': 'ReturnList', 'param0': classificationName.toLowerCase() }),
    success: function (data) {
        data = eval(data);

    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
    },
    beforeSend: function (xhr) {
        xhr.setRequestHeader("X-OFFICIAL-REQUEST", "TRUE"); //Used to ID as a AJAX Request
    },
    complete: function (XMLHttpRequest, textStatus) {
     //build HTML
        var tablestring = '<table ><tr><td>UsreID" + "</td><td>UserName</td></tr>';

        for (var i = 0, len = data.length; i < len; ++i) {
            tablestring = tablestring + "<tr>";
            tablestring = tablestring + "<td>" +
                data[i].BusinessID + "</td>";
            tablestring = tablestring + "<td>" +
                data[i].BusinessName + "</td>";
            tablestring = tablestring + "</tr>";
        }
        tablestring = tablestring + "</table>";
        var divResult = document.getElementById("divAjax");
        divResult.innerHTML = tablestring;

    }
}); 

The http call is executed fine and the collection is serialized and returned with the response however I have a few problems here. The main one is that the HTML is not being created – I am not able to capture the string returned. The string below shows up in the Firebug script window after the call is complete

[{“BusinessID”:6549,”BusinessName”:”Ivory Store”,”IsMain”:true}, {“BusinessID”:16565,”BusinessName”:”Classic Nails”,”IsMain”},{“BusinessID”:5877,”BusinessName”:”Visible Changes Hair”,”IsMain”:true}]

Also in the Firebug I have noticed that string in XMLHttpRequest response object and the error message is “JSON is not valid” Any suggetions? Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:59:46+00:00Added an answer on June 1, 2026 at 1:59 am

    For some reason the code-behind C# parser code below was not appending “]” to the end of the string so I had to append it manually – it worked!!! Thank you.

       public static string Serialize<T>(T obj)
        {
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
            MemoryStream ms = new MemoryStream();
            serializer.WriteObject(ms, obj);
            string retVal = Encoding.UTF8.GetString(ms.ToArray());
            return retVal + "]";
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Rails and jQuery, making an ajax call initiated by clicking a
I am making an ajax call using jQuery. I am aware of the success\failure
Going slightly crazy here. I'm making an Ajax call using jQuery.post as follows: $.post('php/print.php',{data:dS},function(res){...
I am making an AJAX calling using JQuery. I get back a JSON object
I'm making a ajax call using jQuery I'm making use of the following options
I'm making an ajax call using jQuery as below. $.ajax({ type: POST, url: proc.php,
I'm using jQuery Validate for my form validation. I'm making an Ajax call to
I'm making a standard JQuery .ajax call, already jumped through hoops to get it
I m making an ajax call using jQuery to an ASP.NET page which acts
My encoding is set to ISO-8859-1. I'm making an AJAX call using jQuery.ajax to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.