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 9177219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:16:26+00:00 2026-06-17T17:16:26+00:00

var req = $.ajax({ type: ‘GET’, cache: false, url: ‘loc.aspx?count=’ + str, dataType: ‘json’,

  • 0
var req = $.ajax({
            type: 'GET',
            cache: false,
            url: 'loc.aspx?count=' + str,
            dataType: 'json',
            contentType: "application/json; charset=utf-8",
            async: false,
            data:'{}',
            success: function (data) {
                alert(data.responseText);
            }
        });
        req.fail(function (data) {
        TINY.box.show({ html: 'Server Error. Try again: ' + data.responseText, animate: false, close: false, boxid: 'error', top: 100 });
        });

the above code used to work right in jsp, now i am trying to use in asp.net c#, any way I am getting correct data in error block which i want it in success block. Even data.d is not helping,

If i write something like alert(data) i am getting the complete html, I need just the response text, When i use like this data.responseText, I am getting undefined. Someone help pls.

Thanks

  • 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-17T17:16:27+00:00Added an answer on June 17, 2026 at 5:16 pm

    Code below should work fine. I’ve added some comments where you are doing a mistake

    var req = $.ajax({
                type: 'GET',
                cache: false,
                url: 'loc.aspx?count=' + str,
                dataType: 'html',// as you return a simple html dataType:json will throw an error as jquery will not be able to parse received string
                contentType: "application/json; charset=utf-8",
                async: false,
                data:'{}',
                success: function (data) {
                    alert(data);// data is not an XHR object. it is a processed response. In your case - simple string with HTML which, of course, has no method responseText
                }
            });
            req.fail(function (data) {
            TINY.box.show({ html: 'Server Error. Try again: ' + data.responseText, animate: false, close: false, boxid: 'error', top: 100 });
            });
    

    In .fail function you have data.responseText because in this case XHR object is passed as a first parameter (See this). At the same time, first parameter of success callback is a clean data received with request. If without details, you can think that data == xhr.responseText in success callback. See success property description in this section

    upd

    As appeared, problem is not only with JS. I guess you have a simple .aspx page which is called with ajax. There are two solutions:

    1) Use webservice instead. It will be better because it does not go through complete page load cycle and should be executed faster. And it will not produce unused HTML

    2) aspx page will output some HTML by default. Before you return a response for ajax request, you should clear response (so HTML which is already generated will not be sent to a server), write your response and immediately end it:

    Response.Clear();
    Response.Write("hello");
    Response.End();
    

    This way you should receive only hello in success.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following request: var response = $.ajax({ type: POST, contentType: application/x-www-form-urlencoded, url:
var jqopt = new jQueryAjaxOptions { Url = Model.Helper.ServiceEndpoint, Type = Get }; var
var http = require('http'); http.createServer(function (req, res) { if (req.url == '/') { req.url
For example suppose I have the following app.get('/', function(req, res) { var ip; if(req.headers['x-forwarded-for']){
I have this code working, from this example : var url = function(req, res){
I have a html page that triggers an ajax request: $.ajax({ type: 'POST', url:
I'm looking at this code snippet: var addSnippet = function( req, res ) {
Here's the code: exports.index_post = function(req, res) { var nicks = []; if (req.body.nick)
In my app I have the following: client.on('test', function(req, fn) { var returnArr =
I'm trying to make an AJAX GET request, but I simply cannot get it

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.