JQuery AJAX HTML response in error function

Ramesh Murugesan
var id = 45;        
$.ajax({
            url :'url', // This URL response some HTML content
            type: 'POST',
            dataType: 'json',
            data :{ID:id},
            success:function(data)
            {
                console.log(data); // No Response here
            },
            error : function (error){
                console.log(error); // error.responseText contain html content
            }
        });

I render HTML content by JQuery AJAX. The HTML response comes from error function instead of success function. is any mistake from my side?

Frebin Francis

Use html instead of json for datatype

The datatype property specifies the type of data that you're expecting back from the server

$.ajax({
                url :'url', // This URL response some HTML content
                type: 'POST',
                dataType: 'html',
                data :{ID:id},
                success:function(data)
                {
                    console.log(data); // No Response here
                },
                error : function (error){
                    console.log(error); // error.responseText contain html content
                }
            });

See the Jquery Api for more details

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

JQuery AJAX HTML response in error function

From Dev

jQuery target html from ajax response using a separate function

From Dev

Call function in jQuery from AJAX response

From Dev

jQuery Ajax passing response variable to function

From Dev

jQuery get response from ajax function

From Dev

Unable to use jquery.html() with ajax response

From Dev

Jquery ajax response rendered as HTML instead of JS

From Dev

JQuery $.ajax set cookie and get html response

From Dev

Jquery ajax response rendered as HTML instead of JS

From Dev

How to split the Response html of ajax in jquery

From Dev

JQuery.ajax does not wait for C# Server's response and calls error function, testing on localhost

From Dev

Ajax Call using Jquery in HTML and take a response to other Html Page

From Dev

Calling function inside jQuery ajax success response works once but not twice

From Dev

jQuery .each function runs over and ajax response showing later

From Dev

How to set jquery function for all of <a> element in ajax response

From Dev

jquery ajax- get response string from a function

From Dev

jQuery/Ajax success function not rendering html

From Dev

Why can't I parse a Ajax html GET response in jQuery?

From Dev

Remove HTML Elements from JQuery AJAX load() Response

From Dev

How to access ajax response data as html with javascript or jquery?

From Dev

How to collect collect data from Jquery ajax response to html?

From Dev

How to get jQuery ajax to execute error function

From Dev

Ajax function with Jquery returns 400 error

From Dev

Ajax success and error function is not calling properly in jquery

From Dev

jQuery ajax call getting error response with status of 200

From Dev

jQuery ajax call getting error response with status of 200

From Dev

jquery AJAX get encountering undefined error for valid json response

From Dev

jQuery ajax cache response

From Dev

jQuery - response of ajax

Related Related

  1. 1

    JQuery AJAX HTML response in error function

  2. 2

    jQuery target html from ajax response using a separate function

  3. 3

    Call function in jQuery from AJAX response

  4. 4

    jQuery Ajax passing response variable to function

  5. 5

    jQuery get response from ajax function

  6. 6

    Unable to use jquery.html() with ajax response

  7. 7

    Jquery ajax response rendered as HTML instead of JS

  8. 8

    JQuery $.ajax set cookie and get html response

  9. 9

    Jquery ajax response rendered as HTML instead of JS

  10. 10

    How to split the Response html of ajax in jquery

  11. 11

    JQuery.ajax does not wait for C# Server's response and calls error function, testing on localhost

  12. 12

    Ajax Call using Jquery in HTML and take a response to other Html Page

  13. 13

    Calling function inside jQuery ajax success response works once but not twice

  14. 14

    jQuery .each function runs over and ajax response showing later

  15. 15

    How to set jquery function for all of <a> element in ajax response

  16. 16

    jquery ajax- get response string from a function

  17. 17

    jQuery/Ajax success function not rendering html

  18. 18

    Why can't I parse a Ajax html GET response in jQuery?

  19. 19

    Remove HTML Elements from JQuery AJAX load() Response

  20. 20

    How to access ajax response data as html with javascript or jquery?

  21. 21

    How to collect collect data from Jquery ajax response to html?

  22. 22

    How to get jQuery ajax to execute error function

  23. 23

    Ajax function with Jquery returns 400 error

  24. 24

    Ajax success and error function is not calling properly in jquery

  25. 25

    jQuery ajax call getting error response with status of 200

  26. 26

    jQuery ajax call getting error response with status of 200

  27. 27

    jquery AJAX get encountering undefined error for valid json response

  28. 28

    jQuery ajax cache response

  29. 29

    jQuery - response of ajax

HotTag

Archive