SyntaxError: Invalid regular expression: missing / [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
According to http://www.regexr.com/38o5d my reqex seems to work, but when I implement it into my javascript
var prefix = hash.replace(/\/|#/g, '');
I'll get the following error: SyntaxError: Invalid regular expression: missing /

Psychic debugging: Your code isn't in a plain JavaScript or HTML file, but is being printed from a scripting language in which # is a comment character. The #/g, ''); piece is being treated as a comment in your script.
You need to add some quotes to ensure that the whole line gets printed.

Related

pass php json_encode to jQuery function [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I would like to pass a php array to a jQuery function but I get this error:
SyntaxError: Unexpected token ')'. Expected either a closing ']' or a ',' following an array element.
my code:
function showDetails(data) {
alert(data);
}
<a onclick="showDetails(<? echo json_encode($arr['data']['items']); ?>)">
Click here
</a>
Use single quotes for the onclick attribute due to json double quotes which will cause html to break
<a onclick='showDetails(<? echo json_encode($arr['data']['items']); ?>)'>

How to include Micro symbol (µ) in Javascript regex? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I need to use the following regex in my Javascript code:
/\D*(\d+)\s*([TGMkmµnp]).*/g
However, the µ symbol is causing syntax error.
How can I fix this?
The error message is:
At "value = str.replace(/(+)(TGMk"
error110: SYNTAX ERROR while lexing character "µ".
I am using TestComplete software.
My code is as simple as this:
function GetVoltageDbl(str)
{
var value = str.replace(/\D*(\d+)\s*([TGMkµmnp]).*/g, "$1");
var prefix = str.replace(/\D*(\d+)\s*([TGMkµmnp]).*/g, "$2");
Log.Message(value);
Log.Message(prefix);
}
Try replacing µ with \u03BC as follows:
/\D*(\d+)\s*([TGMkm\u03BCnp]).*/g
Please try this \µ . It's need to help

Syntax Error jQuery [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
there is a syntax I can't figure out.
$(this).append(free);
And here is the error message in the console:
Uncaught SyntaxError: Unexpected token <
I have no idea, what this error message wants to tell me, because it makes no sense to me.
Simple, you are missing quotes:
$(this).append('free');
From the docs the parameter you pass can be:
"DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements."
$(this).append('free');

SyntaxError: missing brackets after argument list [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
Get this JavaScript error, and I don't get well where exactly to add the brackets
Uncaught SyntaxError: missing ) after argument list
function showContacts(){
console.log('Showing Contacts...');
setTimeout("$('#pageContent').load('contacts.php',functions(){$('loaderImage').hide();})",1000);
}
Typo: function should be used instead of functions(Notice extra s at the end)
function showContacts() {
console.log('Showing Contacts...');
setTimeout("$('#pageContent').load('contacts.php',function(){$('loaderImage').hide();})", 1000);
}

Show field when there is input? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
So here's what I'm trying to achieve. http://codepen.io/ifen/pen/mBcCo
In mine http://jsbin.com/jafiwani/1/edit , when I enter something into the form and move on to the next, the box closes up and shows the default name. If you try to put anything into both forms you'll understand what I mean. Any help would be great, I've tried everything I know.
You're just missing jQuery from that jsbin. If you go to "Add Library" at the top and add jQuery 2.1.0 you'll see that it works!
n.b you should always check out the javascript console (available in all browsers by viewing the developer tools) for any javascript errors to see what's going wrong. In this case it says:
Uncaught ReferenceError: $ is not defined
This means that the jQuery library that much of the code here depends on (see anything with a $ - that's jQuery in action) is missing.

Categories

Resources