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?

 Answers

73

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:

http://www.php.net/dom

The usage of this:

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

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
 
CodeCaster
answered 7 Months ago
57

You can use the following:

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

And replace with '' (empty string)

See DEMO

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

Saturday, May 29, 2021
 
Terry
answered 5 Months ago
42

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
 
jsmith
answered 3 Months ago
100

It is not possible right now - there is a related ticket https://youtrack.jetbrains.com/issue/RSRP-434190.

Monday, October 11, 2021
 
bshacklett
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 :
 
Share