pass php json_encode to jQuery function [closed] - javascript

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']); ?>)'>

Related

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);
}

Retuning a string in PHP [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 8 years ago.
Improve this question
I wanted to return following string, but I still couldn't get it done right for couple of hours. CAn anyone tell me what did I do wrong? Thank you.
<?php
return 'rs...#gmail.com.com';
?>
You have single quotes in the JavaScript code in your onclick attribute. You need to escape these by placing a backslash before each single quote.

SyntaxError: Invalid regular expression: missing / [closed]

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.

Categories

Resources