syntax error unexpected string [closed] - string

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have difficulty to solve this string problem
contentString = '<div id="infoHead">Drag me for new coordinates.</br></div>'+results[1].formatted_address+'<div id="latlng">'+
'Latitude: '+dmsLat+'</br>'+'Longitude: '+dmsLng+'</div>'+'</br>'+'<a href="//www.youtube.com/embed/Mzja4le8htk"'
+ 'style="width=420px; height=315px"'
+ 'onclick=' + '"window.open(this.href,'rockclimbing','left=400,top=250,width=420,height=315,toolbar=1,resizable=0');return false;"'
+ '>Click here for more details</a>'
For example through this code:
'"window.open(this.href,'rockclimbing','left=400,top=250,width=420,height=315,toolbar=1,resizable=0');return false;"'
it's show some error where rockclimbing and start from left until sizeable=0 cannot put single quatotion.
So how to solve this problem?
I can't provide the link since this is my second project. Any kind of help I'm really appreciated.

You need to escape the inner quotes:
'"window.open(this.href,\'rockclimbing\',\'left=400,top=250,width=420,height=315,toolbar=1,resizable=0\');return false;"'
Otherwise the single quote before rockclimbing terminates the string.

I will show you how to find your errors.
I am only including our example up to the first error.
As you move this piece into your environment this error should go away, provided
results[1].formatted_address
can be converted to a string.
Move in more and more of your original code as you fix your errors.
Good Luck!
Code Wrapped in Exception Handler for Error Reporting
try {
contentString = '<div id="infoHead">Drag me for new coordinates.</br></div>'
+results[1].formatted_address;
} catch(exception) {
console.log(exception.stack);
}
Console Log Output for Error Diagnosis
ReferenceError: results is not defined
at <anonymous>:2:84
at Object.InjectedScript._evaluateOn (<anonymous>:580:39)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:539:52)
at Object.InjectedScript.evaluate (<anonymous>:458:21)

Related

How to api response change [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to transfer the data into an array and my api response is like this
inside api response there is: locationslist :"[\"Location 2\",\"Location 2\"]"
How to get a clean response in react Js?
And I am also try a JSON.parse() it's give me error
This should do it just fine:
const localtionList = "[\"Location 2\",\"Location 2\"]";
console.log(JSON.parse(localtionList))
You are getting error because you are trying to parse JavaScript object using JSON.parse(). To fix the issue you need to pass JSON string to the JSON.parse() method like following:
const something = {
locationslist :"[\"Location 2\",\"Location 2\"]"
};
// This code will give error
console.log(JSON.parse(something));
// This will work fine because locationslist
// holds a JSON string
console.log(JSON.parse(something.locationslist));

Scraping a website returns an unexpected empty value in Node.JS [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 2 years ago.
Improve this question
I am trying to scrape a player count on a website but my code keeps returning empty. What did I do wrong?
I'm trying to scrape this website: https://www.game-state.com/193.203.39.13:7777/ and the value I want to console.log is Players: x/1000
setInterval(function() {
var url = 'https://www.game-state.com/193.203.39.13:7777/';
request(url, function(err, response, body) {
var $ = cheerio.load(body);
var players = $('.value #players');
var playersText = players.text();
console.log(playersText);
})
}, 300)
Your selector is wrong.
You are selecting any tag with ID players that is inside of a tag with class value. What you want is both checks on the same element. The issue is the space between .value and #players - remove it: .value#players.
A tip: Try it in your browser first... go to the page, open devtools, enter document.querySelector('.value #players') - you'll see it comes back empty. With .value#players it works.
But, since an ID is supposed to be unique, just the ID #players would suffice anyway.

What does underscore wrap function do? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Looking at the example given here (http://underscorejs.org/#wrap), I don't really understand what wrap is doing ... Even more so, when the function is "wrapped" it feels the parameters have to be set (for example, what about doing hello('john')? Are there other examples available that explains what wrap is all about? What would be a typical use case for it?
Thanks!
C
_.wrap() can accept more parameters in callback function other than the function you have. For example to make your hello('John') example work we need some modification on the example code to be
var hello = function(name) { return "hello: " + name; };
hello = _.wrap(hello, function(func,name) {
return "before, " + func(name) + ", after";
});
hello('John');

Deleting/Closing a user does not work [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'm making a call to:
DELETE {baseurl}/accounts/{accountId}/users
Request body contains:
{"users":[{"email":"<an email>"}]}
Response:
ERROR 400 Bad Request
{"errorCode": "INVALID_REQUEST_BODY",
"message": "The request body is missing or improperly formatted."}
What am I missing?
I was able to "delete" the user using RestSharp. So it is an api explorer issue.
Please see the documentation for the correct parameter usage: https://www.docusign.com/p/RESTAPIGuide/RESTAPIGuide.htm#REST%20API%20References/Close%20a%20User.htm?Highlight=delete%20user
FYI I tested and a DELETE worked fine. I used the following JSON.
{
"users":[{
"userId":"7f7d3f01-9894-4479-9108-fee8c250xxxx"
}]
}
I just fixed this in the API explorer. Please try now and let me know in case you are still running into issues.

The Sails.js controller action is called twice during every HTTP request [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 wrote the following example controller using Sails.js:
userController.js
module.exports = {
test: function(req, res){
console.log('test')
res.json('test')
}
};
When I run sails.js and send it to that route (user/test), it appears to execute that code twice and outputs test twice in my WebStorm debug window:
"test"
"test"
How do I keep Sails.js from executing the same code twice?
I couldn't reproduce your issue. I tried really hard to reproduce it.
I created the same controller you have in your question, and I ran the code -- but not in WebStorm, I ran it from the command line. Since you're using console.log("test"), I should be able to see the console output test twice if your code is doing what you're saying it's doing, however, I couldn't get that to happen:
As you can see from the screenshot, the console output test once, and the webbrowser output a response of test, which exactly matches the code you've given:
module.exports = {
test: function(req, res){
console.log('test') //output test to console
res.json('test') //output test to the response
}
};
I can't reproduce the issue as you've shown it; and there's no indication that controller is getting executed twice.

Resources