When I included the jquery mobile javascript file in to the code in order to recognize the tap and tap hold events, in the following code
$("#applyZoom").live("tap", function(event){
alert('binding');
});
I am getting the error "Origin null is not allowed by Access-Control-Allow-Origin."
in the chrome browser.
When I tested in the IOS simulator, no other click event is working.
I am not using any ajax call.
Please help me out to get rid of this error.
What is the jQuery library are you using? live is depreciated as of 1.9. You should use on instead of live. Check whether it solves the issue.
As per the documentation you should do something as below
$( "#applyZoom" ).on( 'tap', tapHandler );
function tapHandler( event ) {
alert("all set");
}
I suppose you are trying to run the files from local directory, instead of a hosted solution. Try to host it in localhost and access via http and see whether you get null origin error. Else try to access via file:/// like url and see.
Related
So it's the first time I'm trying to use the google reCAPTCHA v3 (actually it's the first time I'm using any kind of captcha).
I followed the documentation and a very basic tutorial.
What I understand is that I should be able to see the token in my browser inspector.
The first issue is that i can see the logo on the bottom right of my screen, but there is definitely no token in my input.
The second issue comes from the browser console which indicates 3 kind of errors.
I'm working with Symfony Framework on a local environment.
Any clue would be much appreciated !
My twig & javascript files
Browser screenshot
Content-Security-Policy issues
So i figured out how to get the token....
I just had to remove those lines in the js file:
function onclick(e) {
e.preventDefault();
I still didn't find about the Content-Policy issues.
I'm developing a Windows phone 8.1 app and there's this scenario where I should open the webview for the user to enter the card details. Once the card details are entered and processed, the payment API will send the transaction details back as a POST request to the webview. I'm not able to get the POST data, tried so many methods.
How do I get the post data returned back from the server? Thanks in Advance
If you have access to webpage code then you can use WebBrowser.ScriptNotify for transfering data from webpage to WP
Found a way to do this, actually the Server POST request had all the arguments in the Querystring itself
Handled the Navigation_Completed event of the webview, the args URI will have all the details required
Answer for UWP.
Important Note: I have html document locally in localcache folder. I open it in webview using ms-appdata:// scheme.
Story of infinite troubles (may be it some you some time):
If I sent the POST request, I got nothing. I get WebView_NavigationStarting event, but the Uri only was transferred. No POST data.
I try to debug using alert. Just to realize that alert doesn't work in WebView.
I found the fix that makes alert works using ScriptNotify events. Just to realize that ScriptNotify doesn't work with ms-appdata:// scheme. So the fix didn't work as well.
I learned how debug in VS by going to Project settings / Debug / Debugger type / Application process and select "Script". Then I realized that I can't put breakpoints in script in Visual Studio. And then I found a little hack -- put the word "debugger;" in your javascript code and VS will stop there. And you can debug using F10/F11. Oh, yeah, baby!
Then I finally gave up and changed it to GET request. Just to realize that it only works until form data exceed ~2K. After that nothing. NavigationStarting never fired, just nothing happens.
Finally, here the solution:
private async void WebView_NavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
{
string result = await this.WebView.InvokeScriptAsync("eval", new string[] { "$('form').serialize()" });
}
Not really elegant, but it works!!! And I was able to transfer 20K+ this way. This is exactly what I needed.
I've just created a new project and installed the file and file-transfer api's via CLI. I have already created a working app previously so I know how to use phonegap and have been doing so for a few years now.
Here is the code:
window.resolveLocalFileSystemURL("file:///localhost/var/mobile/Applications/96B4705C-C70D-4340-9A42-HJ1F28355D43/tmp/cdv_photo_015.jpg", function(fileEntry){
console.log(fileEntry.name);
}, function(error){
console.log('about to resolve this files errors');
console.log(error.code);
});
Nothing ever gets outputted in the console debugging window ...and yes I have debug installed cause I have console.log() in other parts of my code that show up.
It seems like there is an issue when passing URL data from navigator.camera.getPicture() to the file API when using window.resolveLocalFileSystemURL()...any ideas anyone. I'm up to date on phonegap api and everything and I have this issue for the past few days now...I can't seem to solve it.
***EDIT***
Seems like when you use Camera.DestinationType.FILE_URI as a parameter for navigator.camera.getPicture(). When you choose a picture and the success call back for navigator.camera.getPicture() is triggered, trying to window.resolveLocalFileSystemURL from the URL that getPicture returns just fails. But if you set Camera.DestinationType.NATIVE_URI it at least returns something but it's in a format that can't be used with the file-transfer api exp: assets-library://asset/asset.JPG?id=220BCEAE-F1EA-4A6A-83B2-AB8833A90BF2&ext=JPG
Seems like this was a bug in the file api v1.0.0
https://issues.apache.org/jira/browse/CB-6116
Temp solution is there as well.
Seems like "/local/" was causing the issue. Remove it from incoming uri's if it exist and the resolve should work.
I am going through the process of updating a Google Chrome extension from Manifest v1 to Manifest v2. I won't say that things have been going swimmingly, largely due to outdated documentation at Google's own Chrome Extensions website.
Here is the latest:
Google's documentation for using OAuth from within an extension tells me to include the following three files in my manifest:
chrome_ex_oauth.html
chrome_ex_oauth.js
chrome_ex_oauthsimple.js
The first of these files, chrome_ex_oauth.html, is basically the redirect page that is opened when an extension first uses OAuth to get an initial request token. In the updated version of this very spare webpage, the head section lists three javascript files to load: the two listed above, and one called:
onload.js
When chrome_ex_oauth.html is opened by my extension, I get no indication of errors beyond a failure to load the non-existent 'onload.js' file. Clearly, I am missing something here. The OAuth sequence never succeeds in completing, and indeed there is no indication that it is ever initiated.
Does anybody know what I'm doing wrong?
After posting this question, I compared the old and new versions of chrome_ex_oauth.html. I saw that in the former, while there was no mention of the onload.js script, there was the following in the head:
<script type="text/javascript">
function onLoad() {
ChromeExOAuth.initCallbackPage();
};
</script>
This function was called inline:
<body onload="onload();">
...
As of Manifest v2, it is my understanding that inline javascript is strictly prohibited, so this couldn't fly. A call to load onload.js was added to the document head instead. It looks as if a link to the actual file in Google's documentation was overlooked. It's easy enough to write, but here is what I put in onload.js:
window.onload = function() { ChromeExOAuth.initCallbackPage(); };
After that, the redirect worked just fine and I was able to complete the OAuth process.
Let me know if it doesn't work for you.
I am trying to create a chrome extension that calls my rails app's api. currently the api returns json and it works fine, however when I try to build it into a chrome extension, it says :
Refused to load script from 'http://mysite.com/demo?q=hello?callback=jQuery16409466155741829425_1342489669670&_=1342489677171' because of Content-Security-Policy.
I looked up the document http://code.google.com/chrome/extensions/contentSecurityPolicy.html and it sounds like I can't do this unless I implement my site into a https version. (under "Relaxing the default policy" section) I am not sure if I understood correctly and it feels ridiculous to make such a big change just because of this. Am I misunderstood? Or is there a workaround to this? Thank you.
In a Chrome extension, cross-site XMLHttpRequests are allowed, provided that you define the source in the manifest file - see http://code.google.com/chrome/extensions/xhr.html.
A JSONP implementation loads an external script using the <script> tag, and inserts it in the document. Unless the source is whitelisted through the "content_security_policy" entry, JSONP cannot be used when manifest version 2 is active (do not use manifest v1 to overcome this, because it's deprecated, and a suitable alternative already exist).
When you're unable to receive a JSON response instead of JSONP, use an ordinary request to fetch the data, cut off the callback, then parse it. Eg:
// response is the response from the server
// Received through `XMLHttpRequest`, jQuery.ajax, or whatever you used
// cuts of jQuery....( and the trailing )
response = response.replace(/^[^(]*\(/, '').replace(/\);?$/, '');
By default browsers do not allow this because of the same origin policy.
However you can get around this by making a jsonp request.
As you using jquery this super easy with getJSON method