Uncaught TypeError: Cannot read property 'removeChild' of null without using removeChild





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







3















I don't use removeChild() and neither I try remove something before's there something.



jquery-3.3.1.min.js:2 Uncaught TypeError: Cannot read property 'removeChild' of null
at m (jquery-3.3.1.min.js:2)
at Function.globalEval (jquery-3.3.1.min.js:2)
at text script (jquery-3.3.1.min.js:2)
at Ut (jquery-3.3.1.min.js:2)
at k (jquery-3.3.1.min.js:2)
at XMLHttpRequest.<anonymous> (jquery-3.3.1.min.js:2)
at Object.send (jquery-3.3.1.min.js:2)
at Function.ajax (jquery-3.3.1.min.js:2)
at Function.w._evalUrl (jquery-3.3.1.min.js:2)
at Re (jquery-3.3.1.min.js:2)


I receive with $.ajax html and I .html() it into a div container.



$(".kontakt").click(function(a) {
$('.opt-out').fadeOut();
a.stopPropagation()
a.preventDefault()

$.ajax({async: true,
type: "POST",
url: "classes/handle.ajax.class.php",
data: {
class: "kontakt"
},
success: function(a) {
$(".link-container").html(a)
$('.link-container').fadeIn();
blur();
}
})
})









share|improve this question























  • In which line javascript stopped?

    – Mohammad
    Nov 24 '18 at 13:52











  • @Mohammad javascript didn't stopped.

    – J.Doe
    Nov 24 '18 at 13:59


















3















I don't use removeChild() and neither I try remove something before's there something.



jquery-3.3.1.min.js:2 Uncaught TypeError: Cannot read property 'removeChild' of null
at m (jquery-3.3.1.min.js:2)
at Function.globalEval (jquery-3.3.1.min.js:2)
at text script (jquery-3.3.1.min.js:2)
at Ut (jquery-3.3.1.min.js:2)
at k (jquery-3.3.1.min.js:2)
at XMLHttpRequest.<anonymous> (jquery-3.3.1.min.js:2)
at Object.send (jquery-3.3.1.min.js:2)
at Function.ajax (jquery-3.3.1.min.js:2)
at Function.w._evalUrl (jquery-3.3.1.min.js:2)
at Re (jquery-3.3.1.min.js:2)


I receive with $.ajax html and I .html() it into a div container.



$(".kontakt").click(function(a) {
$('.opt-out').fadeOut();
a.stopPropagation()
a.preventDefault()

$.ajax({async: true,
type: "POST",
url: "classes/handle.ajax.class.php",
data: {
class: "kontakt"
},
success: function(a) {
$(".link-container").html(a)
$('.link-container').fadeIn();
blur();
}
})
})









share|improve this question























  • In which line javascript stopped?

    – Mohammad
    Nov 24 '18 at 13:52











  • @Mohammad javascript didn't stopped.

    – J.Doe
    Nov 24 '18 at 13:59














3












3








3


0






I don't use removeChild() and neither I try remove something before's there something.



jquery-3.3.1.min.js:2 Uncaught TypeError: Cannot read property 'removeChild' of null
at m (jquery-3.3.1.min.js:2)
at Function.globalEval (jquery-3.3.1.min.js:2)
at text script (jquery-3.3.1.min.js:2)
at Ut (jquery-3.3.1.min.js:2)
at k (jquery-3.3.1.min.js:2)
at XMLHttpRequest.<anonymous> (jquery-3.3.1.min.js:2)
at Object.send (jquery-3.3.1.min.js:2)
at Function.ajax (jquery-3.3.1.min.js:2)
at Function.w._evalUrl (jquery-3.3.1.min.js:2)
at Re (jquery-3.3.1.min.js:2)


I receive with $.ajax html and I .html() it into a div container.



$(".kontakt").click(function(a) {
$('.opt-out').fadeOut();
a.stopPropagation()
a.preventDefault()

$.ajax({async: true,
type: "POST",
url: "classes/handle.ajax.class.php",
data: {
class: "kontakt"
},
success: function(a) {
$(".link-container").html(a)
$('.link-container').fadeIn();
blur();
}
})
})









share|improve this question














I don't use removeChild() and neither I try remove something before's there something.



jquery-3.3.1.min.js:2 Uncaught TypeError: Cannot read property 'removeChild' of null
at m (jquery-3.3.1.min.js:2)
at Function.globalEval (jquery-3.3.1.min.js:2)
at text script (jquery-3.3.1.min.js:2)
at Ut (jquery-3.3.1.min.js:2)
at k (jquery-3.3.1.min.js:2)
at XMLHttpRequest.<anonymous> (jquery-3.3.1.min.js:2)
at Object.send (jquery-3.3.1.min.js:2)
at Function.ajax (jquery-3.3.1.min.js:2)
at Function.w._evalUrl (jquery-3.3.1.min.js:2)
at Re (jquery-3.3.1.min.js:2)


I receive with $.ajax html and I .html() it into a div container.



$(".kontakt").click(function(a) {
$('.opt-out').fadeOut();
a.stopPropagation()
a.preventDefault()

$.ajax({async: true,
type: "POST",
url: "classes/handle.ajax.class.php",
data: {
class: "kontakt"
},
success: function(a) {
$(".link-container").html(a)
$('.link-container').fadeIn();
blur();
}
})
})






javascript jquery






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 13:32









J.DoeJ.Doe

608




608













  • In which line javascript stopped?

    – Mohammad
    Nov 24 '18 at 13:52











  • @Mohammad javascript didn't stopped.

    – J.Doe
    Nov 24 '18 at 13:59



















  • In which line javascript stopped?

    – Mohammad
    Nov 24 '18 at 13:52











  • @Mohammad javascript didn't stopped.

    – J.Doe
    Nov 24 '18 at 13:59

















In which line javascript stopped?

– Mohammad
Nov 24 '18 at 13:52





In which line javascript stopped?

– Mohammad
Nov 24 '18 at 13:52













@Mohammad javascript didn't stopped.

– J.Doe
Nov 24 '18 at 13:59





@Mohammad javascript didn't stopped.

– J.Doe
Nov 24 '18 at 13:59












1 Answer
1






active

oldest

votes


















2














Looking at the source code, I found how ajax is being setup:



jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /b(?:java|ecma)scriptb/
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text ); /* note to this method */
return text;
}
}
} );


So, let's look at globalEval method:



globalEval: function( code ) {
DOMEval( code );
},


And now dive into DOMEval method:



function DOMEval( code, doc, node ) {
doc = doc || document;

var i,
script = doc.createElement( "script" );

script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
if ( node[ i ] ) {
script[ i ] = node[ i ];
}
}
}
/* removeChild is being called */
doc.head.appendChild( script ).parentNode.removeChild( script );
}


Where, you may know the parentNode is null and calling removeChild on null throws an error. Here, in the preceding code, you can see the script has text property assigned which value is set as code. The code is argument of DOMEval method. Which actually is the text argument as you can find in ajaxSetup.



The ajaxSetup is being called on ajax method (you can look into the source). Which has url and options arguments. And in the options argument you can find dataType property is used. And if the dataType is not set, it will guess its type in which the server may return a response of null or {}.



So, I suggest you to set the proper dataType while using jQuery.ajax. This should fix your issue.



Update:



Well, if the response returned by the server is malformed then also it may throw you an error. Thus, verify the server is returning good response. As per your comment, I debugged the code and found response is not returning quite good.



You have the following html in your response as well which is causing the issue:



<head>
<meta name='robots' content='noindex'>
</head>


Please remove them from the response source, then this should fix the issue.






share|improve this answer


























  • I've added it to my ajax call but it didn't changed anything :/ $.ajax({async: true, type: "POST", url: "classes/handle.ajax.class.php", dataType: "text", data: { class: "kontakt" }, success: function(a) { $(".link-container").html(a) $('.link-container').fadeIn(); blur(); } })

    – J.Doe
    Nov 24 '18 at 15:04













  • even If I use as ProcessData = html nothing is changing. The weird thing is on localhost I don't get this error ...

    – J.Doe
    Nov 24 '18 at 23:34











  • Maybe the website link could help. photo.core-studio.de It happens when you click on "Datenschutz", "Urheberschaft" and "Impressum". Not at "Kontakt"

    – J.Doe
    Nov 24 '18 at 23:37






  • 1





    updated as per your query.

    – Bhojendra Rauniyar
    Nov 25 '18 at 6:31






  • 1





    THANKS! Worked.

    – J.Doe
    Nov 26 '18 at 18:01












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458658%2funcaught-typeerror-cannot-read-property-removechild-of-null-without-using-rem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Looking at the source code, I found how ajax is being setup:



jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /b(?:java|ecma)scriptb/
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text ); /* note to this method */
return text;
}
}
} );


So, let's look at globalEval method:



globalEval: function( code ) {
DOMEval( code );
},


And now dive into DOMEval method:



function DOMEval( code, doc, node ) {
doc = doc || document;

var i,
script = doc.createElement( "script" );

script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
if ( node[ i ] ) {
script[ i ] = node[ i ];
}
}
}
/* removeChild is being called */
doc.head.appendChild( script ).parentNode.removeChild( script );
}


Where, you may know the parentNode is null and calling removeChild on null throws an error. Here, in the preceding code, you can see the script has text property assigned which value is set as code. The code is argument of DOMEval method. Which actually is the text argument as you can find in ajaxSetup.



The ajaxSetup is being called on ajax method (you can look into the source). Which has url and options arguments. And in the options argument you can find dataType property is used. And if the dataType is not set, it will guess its type in which the server may return a response of null or {}.



So, I suggest you to set the proper dataType while using jQuery.ajax. This should fix your issue.



Update:



Well, if the response returned by the server is malformed then also it may throw you an error. Thus, verify the server is returning good response. As per your comment, I debugged the code and found response is not returning quite good.



You have the following html in your response as well which is causing the issue:



<head>
<meta name='robots' content='noindex'>
</head>


Please remove them from the response source, then this should fix the issue.






share|improve this answer


























  • I've added it to my ajax call but it didn't changed anything :/ $.ajax({async: true, type: "POST", url: "classes/handle.ajax.class.php", dataType: "text", data: { class: "kontakt" }, success: function(a) { $(".link-container").html(a) $('.link-container').fadeIn(); blur(); } })

    – J.Doe
    Nov 24 '18 at 15:04













  • even If I use as ProcessData = html nothing is changing. The weird thing is on localhost I don't get this error ...

    – J.Doe
    Nov 24 '18 at 23:34











  • Maybe the website link could help. photo.core-studio.de It happens when you click on "Datenschutz", "Urheberschaft" and "Impressum". Not at "Kontakt"

    – J.Doe
    Nov 24 '18 at 23:37






  • 1





    updated as per your query.

    – Bhojendra Rauniyar
    Nov 25 '18 at 6:31






  • 1





    THANKS! Worked.

    – J.Doe
    Nov 26 '18 at 18:01
















2














Looking at the source code, I found how ajax is being setup:



jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /b(?:java|ecma)scriptb/
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text ); /* note to this method */
return text;
}
}
} );


So, let's look at globalEval method:



globalEval: function( code ) {
DOMEval( code );
},


And now dive into DOMEval method:



function DOMEval( code, doc, node ) {
doc = doc || document;

var i,
script = doc.createElement( "script" );

script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
if ( node[ i ] ) {
script[ i ] = node[ i ];
}
}
}
/* removeChild is being called */
doc.head.appendChild( script ).parentNode.removeChild( script );
}


Where, you may know the parentNode is null and calling removeChild on null throws an error. Here, in the preceding code, you can see the script has text property assigned which value is set as code. The code is argument of DOMEval method. Which actually is the text argument as you can find in ajaxSetup.



The ajaxSetup is being called on ajax method (you can look into the source). Which has url and options arguments. And in the options argument you can find dataType property is used. And if the dataType is not set, it will guess its type in which the server may return a response of null or {}.



So, I suggest you to set the proper dataType while using jQuery.ajax. This should fix your issue.



Update:



Well, if the response returned by the server is malformed then also it may throw you an error. Thus, verify the server is returning good response. As per your comment, I debugged the code and found response is not returning quite good.



You have the following html in your response as well which is causing the issue:



<head>
<meta name='robots' content='noindex'>
</head>


Please remove them from the response source, then this should fix the issue.






share|improve this answer


























  • I've added it to my ajax call but it didn't changed anything :/ $.ajax({async: true, type: "POST", url: "classes/handle.ajax.class.php", dataType: "text", data: { class: "kontakt" }, success: function(a) { $(".link-container").html(a) $('.link-container').fadeIn(); blur(); } })

    – J.Doe
    Nov 24 '18 at 15:04













  • even If I use as ProcessData = html nothing is changing. The weird thing is on localhost I don't get this error ...

    – J.Doe
    Nov 24 '18 at 23:34











  • Maybe the website link could help. photo.core-studio.de It happens when you click on "Datenschutz", "Urheberschaft" and "Impressum". Not at "Kontakt"

    – J.Doe
    Nov 24 '18 at 23:37






  • 1





    updated as per your query.

    – Bhojendra Rauniyar
    Nov 25 '18 at 6:31






  • 1





    THANKS! Worked.

    – J.Doe
    Nov 26 '18 at 18:01














2












2








2







Looking at the source code, I found how ajax is being setup:



jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /b(?:java|ecma)scriptb/
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text ); /* note to this method */
return text;
}
}
} );


So, let's look at globalEval method:



globalEval: function( code ) {
DOMEval( code );
},


And now dive into DOMEval method:



function DOMEval( code, doc, node ) {
doc = doc || document;

var i,
script = doc.createElement( "script" );

script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
if ( node[ i ] ) {
script[ i ] = node[ i ];
}
}
}
/* removeChild is being called */
doc.head.appendChild( script ).parentNode.removeChild( script );
}


Where, you may know the parentNode is null and calling removeChild on null throws an error. Here, in the preceding code, you can see the script has text property assigned which value is set as code. The code is argument of DOMEval method. Which actually is the text argument as you can find in ajaxSetup.



The ajaxSetup is being called on ajax method (you can look into the source). Which has url and options arguments. And in the options argument you can find dataType property is used. And if the dataType is not set, it will guess its type in which the server may return a response of null or {}.



So, I suggest you to set the proper dataType while using jQuery.ajax. This should fix your issue.



Update:



Well, if the response returned by the server is malformed then also it may throw you an error. Thus, verify the server is returning good response. As per your comment, I debugged the code and found response is not returning quite good.



You have the following html in your response as well which is causing the issue:



<head>
<meta name='robots' content='noindex'>
</head>


Please remove them from the response source, then this should fix the issue.






share|improve this answer















Looking at the source code, I found how ajax is being setup:



jQuery.ajaxSetup( {
accepts: {
script: "text/javascript, application/javascript, " +
"application/ecmascript, application/x-ecmascript"
},
contents: {
script: /b(?:java|ecma)scriptb/
},
converters: {
"text script": function( text ) {
jQuery.globalEval( text ); /* note to this method */
return text;
}
}
} );


So, let's look at globalEval method:



globalEval: function( code ) {
DOMEval( code );
},


And now dive into DOMEval method:



function DOMEval( code, doc, node ) {
doc = doc || document;

var i,
script = doc.createElement( "script" );

script.text = code;
if ( node ) {
for ( i in preservedScriptAttributes ) {
if ( node[ i ] ) {
script[ i ] = node[ i ];
}
}
}
/* removeChild is being called */
doc.head.appendChild( script ).parentNode.removeChild( script );
}


Where, you may know the parentNode is null and calling removeChild on null throws an error. Here, in the preceding code, you can see the script has text property assigned which value is set as code. The code is argument of DOMEval method. Which actually is the text argument as you can find in ajaxSetup.



The ajaxSetup is being called on ajax method (you can look into the source). Which has url and options arguments. And in the options argument you can find dataType property is used. And if the dataType is not set, it will guess its type in which the server may return a response of null or {}.



So, I suggest you to set the proper dataType while using jQuery.ajax. This should fix your issue.



Update:



Well, if the response returned by the server is malformed then also it may throw you an error. Thus, verify the server is returning good response. As per your comment, I debugged the code and found response is not returning quite good.



You have the following html in your response as well which is causing the issue:



<head>
<meta name='robots' content='noindex'>
</head>


Please remove them from the response source, then this should fix the issue.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 25 '18 at 6:30

























answered Nov 24 '18 at 14:09









Bhojendra RauniyarBhojendra Rauniyar

53.3k2184136




53.3k2184136













  • I've added it to my ajax call but it didn't changed anything :/ $.ajax({async: true, type: "POST", url: "classes/handle.ajax.class.php", dataType: "text", data: { class: "kontakt" }, success: function(a) { $(".link-container").html(a) $('.link-container').fadeIn(); blur(); } })

    – J.Doe
    Nov 24 '18 at 15:04













  • even If I use as ProcessData = html nothing is changing. The weird thing is on localhost I don't get this error ...

    – J.Doe
    Nov 24 '18 at 23:34











  • Maybe the website link could help. photo.core-studio.de It happens when you click on "Datenschutz", "Urheberschaft" and "Impressum". Not at "Kontakt"

    – J.Doe
    Nov 24 '18 at 23:37






  • 1





    updated as per your query.

    – Bhojendra Rauniyar
    Nov 25 '18 at 6:31






  • 1





    THANKS! Worked.

    – J.Doe
    Nov 26 '18 at 18:01



















  • I've added it to my ajax call but it didn't changed anything :/ $.ajax({async: true, type: "POST", url: "classes/handle.ajax.class.php", dataType: "text", data: { class: "kontakt" }, success: function(a) { $(".link-container").html(a) $('.link-container').fadeIn(); blur(); } })

    – J.Doe
    Nov 24 '18 at 15:04













  • even If I use as ProcessData = html nothing is changing. The weird thing is on localhost I don't get this error ...

    – J.Doe
    Nov 24 '18 at 23:34











  • Maybe the website link could help. photo.core-studio.de It happens when you click on "Datenschutz", "Urheberschaft" and "Impressum". Not at "Kontakt"

    – J.Doe
    Nov 24 '18 at 23:37






  • 1





    updated as per your query.

    – Bhojendra Rauniyar
    Nov 25 '18 at 6:31






  • 1





    THANKS! Worked.

    – J.Doe
    Nov 26 '18 at 18:01

















I've added it to my ajax call but it didn't changed anything :/ $.ajax({async: true, type: "POST", url: "classes/handle.ajax.class.php", dataType: "text", data: { class: "kontakt" }, success: function(a) { $(".link-container").html(a) $('.link-container').fadeIn(); blur(); } })

– J.Doe
Nov 24 '18 at 15:04







I've added it to my ajax call but it didn't changed anything :/ $.ajax({async: true, type: "POST", url: "classes/handle.ajax.class.php", dataType: "text", data: { class: "kontakt" }, success: function(a) { $(".link-container").html(a) $('.link-container').fadeIn(); blur(); } })

– J.Doe
Nov 24 '18 at 15:04















even If I use as ProcessData = html nothing is changing. The weird thing is on localhost I don't get this error ...

– J.Doe
Nov 24 '18 at 23:34





even If I use as ProcessData = html nothing is changing. The weird thing is on localhost I don't get this error ...

– J.Doe
Nov 24 '18 at 23:34













Maybe the website link could help. photo.core-studio.de It happens when you click on "Datenschutz", "Urheberschaft" and "Impressum". Not at "Kontakt"

– J.Doe
Nov 24 '18 at 23:37





Maybe the website link could help. photo.core-studio.de It happens when you click on "Datenschutz", "Urheberschaft" and "Impressum". Not at "Kontakt"

– J.Doe
Nov 24 '18 at 23:37




1




1





updated as per your query.

– Bhojendra Rauniyar
Nov 25 '18 at 6:31





updated as per your query.

– Bhojendra Rauniyar
Nov 25 '18 at 6:31




1




1





THANKS! Worked.

– J.Doe
Nov 26 '18 at 18:01





THANKS! Worked.

– J.Doe
Nov 26 '18 at 18:01




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458658%2funcaught-typeerror-cannot-read-property-removechild-of-null-without-using-rem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()