Jump to content

[SOLVED] JS: Uncaught TypeError: Cannot read property 'autocomplete' of undefined


root

Recommended Posts

Hi all,

for a few days I met an error on my website, Google Chrome give me this information :

Uncaught TypeError: Cannot read property 'autocomplete' of undefined
    at HTMLDocument.<anonymous> (ps_searchbar.js:7)
    at fire (core.js:sourcemap:690)
    at Object.fireWith [as resolveWith] (core.js:sourcemap:711)
    at Function.ready (core.js:sourcemap:745)
    at HTMLDocument.completed (core.js:sourcemap:748)
(anonymous) @ ps_searchbar.js:7
fire @ core.js:sourcemap:690
fireWith @ core.js:sourcemap:711
ready @ core.js:sourcemap:745
completed @ core.js:sourcemap:748

I think there is something wrong but I can't find the problem, I used 2 days to find it, but no result.

It is a little bit hard because now no JS is working...

Can you help me to find what is the error?

Thanks

 

Edited by root
Add: Solved (see edit history)
Link to comment
Share on other sites

  • 1 month later...

Hi, to solve my problem I just moved JS code into custom.js.

Possible solutions:

1) use custom.js (path_for_your_theme/assets/js)

2) Include JS file in head.tpl file (be wareful with synchronous loading... check it on google for optimization)

<script src='http://url/file.js'></script>

3) Add a JS file in your php module code, using addJS() function or maybe registerJavascript() (I have never tried it)

I hope it could help

Link to comment
Share on other sites

What have you modified to have this error? That is The question.

How to find the problem: 

- Have you added a new module? Try to disable it.

- Have you written/changed a module? Try to disable it.

- Have you edited a tpl file? Send me if possible this file, I will check the content.

- Have you changed the js file content of your theme? Find modification and delete it.

- Use debug mode on prestashop to have more information if it is possible, and tools of your web browser.

 

And, just to know, what don't you know? 

 

Link to comment
Share on other sites

 

Hello, thanks for the answer. I just change css or I put some style in tpl. But notice that I mark an error in ps_searchbar which never touch. I turned it off to see if it was a problem and now he gave me this error:

GET https://......./modules/ajaxcart/views/js/front/pop.js net::ERR_BLOCKED_BY_CLIENT

P.D: Sorry for my inglish

Edited by anamorle (see edit history)
Link to comment
Share on other sites

I had this error in ps_searchbar too, and in my case the problem was in a module I wrote.

I think this error appears because JS is in a global error state and ps_searchbar is the first object to call something in JS. If you disable ps_searchbar, the second one will try to call a JS function (in your case ps_shoppingcart).

So the problem is elsewhere.

Just try to remember all modifications you've done before to get it. In any case, and if you want I can check and test your tpl file and JS files you added (or modified) recently.

An other method : Comment your code, block by block and disable module one at the time until the error disappears. But it is a not recommended and a very long method if you're not lucky :lol:

 

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...
On 5/6/2018 at 2:32 AM, anamorle said:

no, i still have it.

This error occurs in Chrome Browser when you read a property or call a method on an undefined object . Uncaught TypeError: Cannot read property of undefined  error is probably easiest to understand from the perspective of undefined, since undefined is not considered an object type at all (but its own undefined type instead), and properties can only belong to objects within JavaScript. There are a few variations of this error depending on the property you are trying to access. Sometimes instead of undefined it will say null.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

var input1 = document.getElementById('from');

var autocomplete1 = new google.maps.places.Autocomplete(input1);

var input2 = document.getElementById('to');

var autocomplete2 = new google.maps.places.Autocomplete(input2);

 

for more information about code related visit our site:https://www.reddit.com/r/learnjavascript/comments/6uj90l/uncaught_typeerror_cannot_read_property/ or for more assistance visit Data Recovery Dubai Group

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...