I want to change page URL by $windows.location.href. I'm using theses query parameters (parameter values are encoded by java.net.URLEncoder.encode(param, "UTF-8")):
number: Numeric value
src: English characters
path: e.g. https://127.0.0.1/callId=123456
desc: Non-english characters
Whole url example:
/app/index.html#/cm/calls/save?number=23390221&src=phoneNumber&path=http%3A%2F%2F127.0.0.1%2FcallId%3D123456&desc=%D9%81%D8%A7%DB%8C%D9%84+%D8%AA%D9%85%D8%A7%D8%B3+%D8%B5%D9%88%D8%AA%DB%8C
When using $windows.location.href:
$window.location.href = notification.url;
I'm getting following error (only for first time):
Uncaught Error: [$rootScope:infdig] http://errors.angularjs.org/1.4.14/$rootScope/infdig?p0=10&p1=%5B%5D
at angular.js:38
at n.$digest (angular.js:16266)
at angular.js:12606
at angular.js:5943
at p (angular.js:341)
at h (angular.js:5942)
at f (angular.js:5910)
at dispatch (jquery.js:4665)
at r.handle (jquery.js:4333)
But in theses situations i'm not getting any error:
Using only number and src parameters
Using only digit/English characters for path and desc parameters
After first time (This error only occurs if we are visiting that url for first time)
Note: I did not do anything with these parameters in client-side codes yet!
Related
I am saving data in Flask application from a textarea.
After saving it I am trying to receive it back to html via javascript like this:
const item = "{{item}}";
It gives me the following error:
Uncaught SyntaxError: Invalid or unexpected token
On server side I am just retuning lik this:
item = Item.query.filter_by(id=id).first()
item=item.body
Error appears only when i save via textarea with a new line.
How can I fix this?
So far I tried: this works only if I change from '' and "" to template literals ``:
const item = `{{item}}`;
But I am not sure if this method is safe since it makes auto escaping. From jinja2 documentation: "String literals in templates with automatic escaping are considered unsafe because native Python strings are not safe."
Also const item = "{{item | safe}}"; seems not helping.
i am using wordpress rest api v2 for getting data from my working wordpress website to angularjs application. all is working fine but when i want to use post meta like "_ait-item_item-data". its return me an error "undefined".
i am using his code to get post meta :
$scope.fieldOne = $scope.businessDetails.post_meta_fields._ait-item_item-data;
and i want to print:
{{fieldOne}}
i know that the problem with underscore and hyphen but how can i get the meta data with them ?
this is the error in console:
ReferenceError: item_item is not defined
at itemSingleCtrl.js:13
at angular.js:16170
at m.$eval (angular.js:17444)
at m.$digest (angular.js:17257)
at m.$apply (angular.js:17552)
at l (angular.js:11697)
at K (angular.js:11903)
at XMLHttpRequest.y.onload (angular.js:11836)
Since your property contains - in it, you can't use dot notation to access its value. You have to access it like below
$scope.fieldOne = $scope.businessDetails.post_meta_fields["_ait-item_item-data"]
I'm writing an AWS reliant application in javascript and I'm utilizing the AWS CLI to automate the build process for my AWS resources. I'm attempting to create an API Gateway resource with CORS enabled. While calling the put-integration-response method of the api gateway CLI, when I add the --response-parameters argument, I received the following error:
>> Error parsing parameter '--response-parameters': Invalid JSON: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
>> JSON received: {method.response.header.Access-Control-Allow-Origin:'*'}
Here is the --response-parameters argument that is causing issues:
--response-parameters {"method.response.header.Access-Control-Allow-Origin":"\'*\'"}
If it helps, this argument is being fed via the grunt-exec plugin for Grunt. What exactly is causing this issue? I've tried adding more double quotes, but they don't seem to appear in 'JSON received'.
Here is another fix for this problem from here
Basically you use \ before quotes inside of JSON on Windows:
Linux/Mac:
--expression-attribute-values '{ ":u": {"S":"anotherUser"}}'
will be like this on Windows:
--expression-attribute-values '{ \":u\": {\"S\":\"anotherUser\"}}'
Hope it helps to fix your error
I had the same problem while following an AWS Lambda Functions tutorial
where I couldn't get the response-models argument to accept JSON (on Windows 10) no matter what I tried. I finally figured it out: I created a file named response-models.json with the contents on the first line of the file as {"application/json": "Empty"} and I saved it in the current directory. Then as the value of the response-models argument I used file://response-models.json
IMPORTANT: the file must be saved in a format WITHOUT the BOM so that only the ASCII characters will come out of it and no other gibberish. (I used Sublime Text which allows one to save in UTF-8 with no BOM, as well as many other formats.)
Et Voila! I got back the following response:
{
"statusCode": "200",
"responseModels": {
"application/json": "Empty"
}
}
You can encode the static value by "'"'"'*'"'"'".
Example:
aws apigateway put-integration-response --rest-api-id xxxxx --resource-id xxxxxx --http-method GET --status-code 200 --response-parameters '{"method.response.header.Access-Control-Allow-Origin": "'"'"'*'"'"'"}'
I suggest to use the JavaScript SDK to call API Gateway to manage your resources. You can find more information from the SDK documentation.
I have an SPA that needs to support any language. Upon loading, it deploys all the labels in a default language. Within the HTML, these are included as:
:
<label ...>{{Labels.Username}}</label>
:
<label ...>{{Labels.Password}}</label>
:
(This is just an example, not the actual HTML).
Now, upon initial loading, all goes OK. When I attempt to change language (even to the initial default language) I get the following error:
SyntaxError: Unexpected token }
at Object.parse (native)
at pc (http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:14:486)
at Xb (http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:80:157)
at http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:81:70
at n (http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:7:302)
at $c (http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:81:52)
at c (http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:82:235)
at http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:118:182
at m.$eval (http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:132:221)
at m.$digest (http://127.0.0.1:55659/Public_Libs/Angular/angular.min.js:129:233)(anonymous function) # angular.js:12116(anonymous function) # angular.js:8976(anonymous function) # angular.js:14355m.$eval # angular.js:15574m.$digest # angular.js:15385m.$apply # angular.js:15679l # angular.js:10166J # angular.js:10338w.onload # angular.js:10279
I attempted to debug this by setting breakpoints into my JavaScript code at every relevant location, but (as suggested by the error) the issue appears to be within the Angular code. I need to find our what triggers this.
Found the issue. It had to do with the fact that, under certain conditions, the JSON that was received (i.e. its string representation) from the remote server was wrongly formatted.
It took me some time to find this, and it looks to me reasonable to assume that I would reach this much faster had AngularJS provided more clear description of the error (this particular as well as others).
Thanks to those that sent comments and recommendations.
I've created a simple bookmarks service for myself with a REST api built in Node using Express 4:
res.json(200, output); // output is an object
Using POSTman I've tested the api fully and all is working. I'm now trying to load the data with jQuery's $.post function:
$.post( "http://my.uri.com/v1/endpoint").done(function(data){
if(data.status == 'success'){
var table_row;
data.bookmarks.forEach(function(bm){
console.log(bm);
console.log(bm.title);
console.log(bm.dstamp);
table_row = "<tr><td>"+ bm.dstamp +"</td></tr>";
});
} else {
console.error('There was a problem');
console.log(data);
}
});
The console.log calls work just fine and I see the data I expect:
Object {id: 16, uri: "http://www.alaskapublic.org/kska/", title: "KSKA | Alaska Public Media", tags: "radio, npr, alaska", dstamp: 1401206372}
KSKA | Alaska Public Media
1401206372
It's when I try to use one of the object properties that I get the error:
Uncaught SyntaxError: Unexpected token ILLEGAL
This is caused by the line:
table_row = "<tr><td>"+ bm.dstamp +"</td></tr>";
It doesn't seem to matter if the property I'm using is a number or a string. I've tried setting the content header in Express but since POSTman and console.log() are happy without it I don't think it's the problem. What am I missing?
UPDATE
FireFox dev tools report the error as:
SyntaxError: unterminated string literal
There is probably some kind of illegal (invisible) character in the line the error is pointing at.
Select that line along with the lines above and below it, delete them, and type them over again, manually. That should get rid of the invisible characters.