简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM