Okay, I created a flash register for my website, it's very simple.
This is the main code:
var LoadRegisterVaribles:LoadVars = new LoadVars();
LoadRegisterVaribles.onData = function(Varibles:String) {
error_mc.error_txt.text = Varibles;
};
LoadRegisterVaribles.load(
"http://216.120.248.106/register/register.php?username=" + Username_mc.name_txt.text +
"&password=" + Password_mc.pass_txt.text +
"&email=" + Email_mc.email_txt.text +
"&color=" + _root.color_txt.text + "");
What it does is load the register.php and adds the extensions in a fancy flash GUI.
Works perfectly; But when I upload it to my website http://216.120.248.106/, or www.spuffle.in, it does not connect. I have crossdomains.xml, that allow (*) all in every directory, but does not work, the cross domains worked for other things I have on my site, so they are configured properly. I also have Security.AllowDomains
Security.allowDomain('spuffle.in');
Security.allowDomain('spuffle.me');
Security.allowDomain('spuffle.us');
Security.allowDomain('play.spuffle.me');
Security.allowDomain('play.spuffle.in');
Security.allowDomain('play.spuffle.us');
Security.allowDomain('spuffle.me/play/');
Security.allowDomain('spuffle.in/play/');
Security.allowDomain('spuffle.us/play/');
Security.allowDomain('www.spuffle.in');
Security.allowDomain('www.spuffle.me');
Security.allowDomain('www.spuffle.us');
Security.allowDomain('www.spuffle.me/play/');
Security.allowDomain('www.spuffle.in/play/');
Security.allowDomain('www.spuffle.us/play/');
Security.allowDomain('media.spuffle.in/media/');
Security.allowDomain('media.spuffle.me/media/');
Security.allowDomain('media.spuffle.us/media/');
Security.allowDomain('www.spuffle.in/media/');
Security.allowDomain('www.spuffle.me/media/');
Security.allowDomain('www.spuffle.us/media/');
Security.allowDomain('*.spuffle.in/*/');
Security.allowDomain('*.spuffle.me/*/');
Security.allowDomain('*.spuffle.us/*/');
Security.allowDomain('216.120.248.106');
Security.allowDomain('216.120.248.106/register/');
Security.allowDomain('216.120.248.106/register/Pages/');
Security.allowDomain('216.120.248.106/register/register.php');
What can I do??
When you embed the SWF on the HTML page, try setting the allownetworking parameter: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS1EFE2EDA-026D-4d14-864E-79DFD56F87C6.html
Related
I'll try to keep this simple and clear. I'm pretty new to using API's but I'm using the Flickr API to search for and display photos on my website based on a certain tag. For a simple, static web page this is quite simple and I've already got it working as intended. This is the jquery script I found to use:
$(function() {
var apiKey = 'MY_API_KEY_IS_IN_HERE';
var tag = '%23FFLIVE2014-09-03';
var perPage = '25';
var showOnPage = '6';
$.getJSON('http://api.flickr.com/services/rest/?format=json&method='+
'flickr.photos.search&api_key=' + apiKey +
'&tags=' + tag + '&per_page=' + perPage + '&jsoncallback=?',
function(data){
var classShown = 'class="lightbox"';
var classHidden = 'class="lightbox hidden"';
$.each(data.photos.photo, function(i, rPhoto){
var basePhotoURL = 'http://farm' + rPhoto.farm + '.static.flickr.com/'
+ rPhoto.server + '/' + rPhoto.id + '_' + rPhoto.secret;
var thumbPhotoURL = basePhotoURL + '_s.jpg';
var mediumPhotoURL = basePhotoURL + '.jpg';
var photoStringStart = '<a ';
var photoStringEnd = 'title="' + rPhoto.title + '" href="'+
mediumPhotoURL +'"><img src="' + thumbPhotoURL + '" alt="' +
rPhoto.title + '"/></a>;'
var photoString = (i < showOnPage) ?
photoStringStart + classShown + photoStringEnd :
photoStringStart + classHidden + photoStringEnd;
$(photoString).appendTo("#flickr");
});
$("a.lightbox").lightBox();
});
});
Create a #flickr div on a page and load that script, photos tagged #FFLIVE2014-09-03 would be displayed, if there are any. My problem is that the site/page I want to show the photos on is dynamic with data generated from a database. So website.com/page.php is the single page, in the database is data for a certain date and a performance that happened on it (For a band).
So what I'm struggling with is how to dynamically edit the tags searched for in the script. With the above script placed in my page.php obviously page.php?id=1 and page.php?id=261 will show the same photos, because the tags searched will be the same when in fact they should be different, based on the date for the data.
So, is there some way to do this? Generate the correct date tag to search for based on the database data? I can generate the correct tag inside the PHP file itself quite easily, just echo the first part of the tag then the date. But how would I do that in relation to the javascript? I gather it is possible to use PHP within Javascript but that would be outside the database, so it wouldn't know what it was generating.
I hope that makes sense!
I'm learning JavaScript but I want the following thing in my little (self-started) project as soon as possible.
Suppose the page of my website is www.mywebsite.com/myPage.html
Here is a scenario that 10 users are viewing myPage.html from my website. As I make any change to myPage.html from server (being admin), I want all viewers of myPage.html to see refreshed page with new changes taken effect just after I make any change in myPage.html. It should be very fast.
For this I think I'll have to create a button which will refresh the page myPage.html. As I'll make changes to myPage.html, I'll press that button and that button will reload every viewer's browser's page (myPage.html). And they will see the result of modified myPage.html in their browsers.
Kindly explain your answer properly, since I'm a beginner. Which Languages are needed for this?
i think the best option here would be some kind of push implementation / web sockets ... here are a few links to get you started in the right direction ...
Websockets : Using modern HTML5 technology for true server push
Push Notifications to the Browser With Server Sent Events
In the case of socket.io in client side(browser) subscribe every client with a particular channel and make the page reload with javascript when request from server via that channel is recieved. And in server you can broadcast message to that particular channel whenever you want to reload the page.
you can create an AJAX function that is executing in intervals(like every 10 seconds) and this function will connect to server to ask for any update from mysql, so if there's any updates! you notify the user.
so you should create a table in DB to be updated with page update info when you update a page.
AJAX(asynchronous javascript and xml ) is a technology connect to your server without having to use Forms to post, and you can refresh part of your page automatically.
now here is an example:
I wanted to create an online chat, so here is the code:
this code use ajax to post to ChatNotifyController.php to see if theres anyone online,if there's any it will notify the user.
//notify user if someone has or had send a message
setInterval(function(){
xmlhttp.open("POST" , "../controller/ChatNotifyController.php" , true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
if((xmlhttp.response).length > 4)
{
var friendName = (xmlhttp.response).replace(/^\s*$[\n\r]{1,}/gm, '');
var responseArea = document.getElementById( friendName + 'ChatArea');
var x = friendName ;
if(x.indexOf('.') > 0)
{
x = x.replace('.', '\\.');
}
var link = $('#' + x);
var input = $('#' + x + 'ChatInput');
var e = jQuery.Event("keydown");
e.which = 13;
if(link.length > 0)
{
link.click();
input.trigger(e);
}
else
{
var html = "<li><a class=\"onlineUserLink\" id=\"" + friendName + "\" onclick=\"chat(" + "'" + friendName + "'" + ")\" >" + friendName + "</a></li>";
html += "<div class=\"chatDialog\" title=\"'" + friendName + "\"' id=\"'" + friendName + 'ChatDialog' + "'\">";
html += "<div class=\"chatArea\"" + " id=\"'" + friendName + "ChatArea" + "'\">" + "</div>";
html += "<input class=\"chatInput\"" + " id=\"'" + friendName + 'ChatInput' + "'\" size=\"21\" onkeydown=\"chatController(event , '" + friendName + "' , '" + window.user + "')>" + "</div>";
window.onlineArea.innerHTML += html;
var THIS = $('#' + x + 'ChatDialog');
$(function() {
THIS.dialog({
stack: false
});
});
link.click();
input.trigger(e);
}
}
}
else
{
//alert("Error during AJAX call. Please try again #003");
}
}
};
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send("user=" + window.user);
} ,5000);
Since I'm relativly new to the use of php and javascript I ran into this problem while trying to add multiple variables in a URL
I use the following script:
<script>
function refresh() {
var PCWDE = document.getElementById("PC");
var NMWDE = document.getElementById("naam");
var VNMWDE = document.getElementById("voornaam");
var ONDWDE = document.getElementById("onderneming");
var BTWWDE = document.getElementById("btwnummer");
var LNDWDE = document.getElementById("land");
this.document.location.href = "http://example.com/form.php?PCS=" + PCWDE.value "&nm=" + NMWDE.value "&vnm=" + VNMWDE.value "&ond=" + ONDWDE.value "&btw=" + BTWWDE.value "&lnd=" + LNDWDE.value;
}
</script>
That's beeing activated trough the following html code:
<?php
$pc = $_GET['PCS'];
echo '<input type="text" name="pc" id="PC" onblur="refresh()" value="'.$pc.'">'
?>
The main reason for the use of this html code was that I needed to execute a query without submitting the form, while still beeing able to hold the value of the text box even when the page would refresh. The above html code is used multiple times with the use of different ID's.
The problem I face while trying to do this is that my code only works when only adding 1 variable to the URL like so:
this.document.location.href = "http://example.com/form.php?PCS=" + PCWDE.value;
Otherwise it does not work. Either the 'onblur' event fails to work, or the script fails to run.
Is there a way to add the multiple variables to the URL in a similiar way to what i'm doing now?
You forgot plus signs. That's a syntax error and you should see the error message if you open the error console. (on firefox you press control-shift-j)
Shoule be:
this.document.location.href = "http://example.com/form.php?PCS=" + PCWDE.value + "&nm=" + NMWDE.value + "&vnm=" + VNMWDE.value + "&ond=" + ONDWDE.value + "&btw=" + BTWWDE.value + "&lnd=" + LNDWDE.value;
I want to implement a counter which keeps track of the number of times a file is downloaded. The function retrieves files from the google drive and it is printed on to the screen using for loop. Please help with a logic where to implement the counter to keep track of the count.
The function is as follows:
function makeRequest() {
var request = gapi.client.drive.files.list();
request.execute(function(resp) {
for (i=0; i<resp.items.length; i++) {
var titulo = resp.items[i].title;
var fechaUpd = resp.items[i].modifiedDate;
var userUpd = resp.items[i].lastModifyingUserName;
var userEmbed = resp.items[i].embedLink;
var userAltLink = resp.items[i].alternateLink;
var download = resp.items[i].webContentLink;
var hold="Download";
var flag=0;
<!-- var fileInfo = document.createElement('li');
<!-- fileInfo.appendChild(document.createTextNode('TITLE: ' + titulo + ' - LAST MODIF: ' + fechaUpd + ' - BY: ' + userUpd +' url: ' + hold.link(download)));
<!-- document.getElementById('content').appendChild(fileInfo);
document.write(titulo + " ");
document.write(hold.link(download) + "<br>");
<!--flag=1;
}
<!--if(flag!=1){
<!--document.write("not found!");
<!--}
}); ;
}
I am not sure I understand what you want to keep track off.
If you want to a single user to be able to see how many times that user has downloaded a file, it could be implemented in javascript and store the information in a cookie.
If you on the other hand want to see how many times a file has been downloaded by any user, it has to be implemented on the server side using PHP or whatever language you have available.
The key question here is if you can/want to implement the functions on the server or the client side. To do it on the client side you use javascript, to do it on the server side you can use PHP.
I am submitting the form using jquery. Now i need to send form information into external server. The below is the part of my code that submit the form to another server. It works in all browsers except IE which gives me access denied error.
$.ajax({
url:"https://www.thewiseagent.com:443/secure/webcontactAllFields.asp",
type:'POST',
data:"ID=" + $ID + "&Source=" + $Source + "¬ifyCc=" + $notifyCc + "¬ifyBcc=" + $notifyBcc + "&noMail=" + $noMail + "&CFirst=" + $first + "&CLast=" + $last + "&Phone=" + $Phone + "&Fax=" + $Fax + "&CEmail=" + $CEmail + "&Message=" + $message,
success: function() {
}
});
Any help?
You can not make an AJAX call to a different domain. See my answer here: jQuery ajax GET returns 405 Method Not Allowed
That being said if it truely works in other browsers then I'm assuming you're posting to the same domain. Then you have to look at the returned content. There should be no reason you'd get a 405 from IE but not from FF.
I suspect though that this doesn't work with other browsers either, because of the javascript security restrictions.