Benmay
Benmay

Reputation: 347

Ajax request getting / receiving an incomplete response (limitation?)

I'm doing a simple ajax request on a html file to get it's code.

(Actually I don't need the type:"Get", because it doesn't do anything)

jQuery.ajax({
    type: "GET",
    url: "page-2.html",
    dataType: "html",
    success: function(response) {
        alert(response);
    }
});

The response is incomplete. The html file has 400 line sof code but the alert doesn't give me the full file. It is incomplete and stops at line +-130. It seems that there is some character limitation. Is this possible? The same happens when I use $.get()

Note: I also get a "Syntax Error -> page-2.html" in the console. Maybe both issues are connected.

Upvotes: 0

Views: 856

Answers (2)

Shashi Kiran Singh
Shashi Kiran Singh

Reputation: 31

There is no issue with your ajax request because your script is perfectly working.if you get some error with response means there is some mismatched tag or html format issue that's why u got that error in response.

There is not need to encode URL in single quote ('') or double quote ("") in ajax request with this script.

Please verify your html code in page-2.html.

Upvotes: 0

Atul Sharma
Atul Sharma

Reputation: 10720

jQuery.ajax({
    type: "GET",
    url: 'page-2.html',
    dataType: "html",
    success: function(response) {
        console.log(response);
        alert(response);
    }
});

You were missing '' around page-2.html that's why there is error in console.

Upvotes: 1

Related Questions