Mysterious line break is being appended to ajax loaded content

前端 未结 2 478
深忆病人
深忆病人 2021-01-28 04:02

Using either .ajax or .load, I\'m loading content from an .html page into or replace an element. In either case, the content is called and inserted and there is a mysterious new

相关标签:
2条回答
  • 2021-01-28 04:10

    Most text file formats save the file with a final line break character at EOF. Assuming you're treating this html file like a server side include, that's probably causing your symptoms.

    0 讨论(0)
  • 2021-01-28 04:26

    Try copy/pasting the code to a different editor (like notepad in windows). Many text editors are able to use different OS's line breaks, and I've seen some that can't delete the line breaks of types other than the one it is set to use. For example, one text editor put Mac line breaks at the end of the file, I open it in Windows and my text editor does not display or indicate those breaks at all. Notepad pretty much just ignores everything it doesn't know about, so when you paste into there, it gets rid of the extra breaks.

    Unless you are seeing the effect with ALL AJAX requests using ANY file, this is probably the culprit.

    0 讨论(0)
提交回复
热议问题