Asked  7 Months ago    Answers:  5   Viewed   29 times

Whenever we are fetching some user inputed content with some editing from the database or similar sources, we might retrieve the portion which only contains the opening tag but no closing.

This can hamper the website's current layout.

Is there a clientside or serverside way of fixing this?



Found a great answer for this one:

Use PHP 5 and use the loadHTML() method of the DOMDocument object. This auto parses badly formed HTML and a subsequent call to saveXML() will output the valid HTML. The DOM functions can be found here:

The usage of this:

$doc = new DOMDocument();
$yourText = $doc->saveHTML();
Wednesday, March 31, 2021
answered 7 Months ago

dataType - delete this one.

Add console.log and open console in Your browser

success: function (data) {
   console.log( data );

show Your console, and then You will see why. Maybe an unwanted char or php error

Second thing - there should be if stament like this (I supposed)

if (data == "1") // it is returning string, not integer.

You can also try to use switch case in success.

Wednesday, March 31, 2021
answered 7 Months ago

You can use the following:

<([^>s]+)[^>]*>(?:s*(?:<br />|&nbsp;|&thinsp;|&ensp;|&emsp;|&#8201;|&#8194;|&#8195;)s*)*</1>

And replace with '' (empty string)


Note: This will also work for empty html tags with attributes.

Saturday, May 29, 2021
answered 5 Months ago

Go to

Settings / Languages & Frameworks / JavaScript

(it may be Preferences / Languages & Frameworks / JavaScript on some OSes)

...and set the "JavaScript language version" to "ECMAScript 6" (or, if they've updated to reflect current naming, "ECMAScript 2015" — or "ECMAScript 2016" or later if you're coding to a newer spec):

enter image description here

Wednesday, August 4, 2021
answered 3 Months ago

It is not possible right now - there is a related ticket

Monday, October 11, 2021
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :