Firefox Extension: about communication with the server
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Firefox Extension: about communication with the server
How can an extension communicate with a server?
how do they exchange data?
suppose u sign in to a page, how does the connection between th extension and server be after sign in?
how does the server send a message to one of these signed in clients?
i tried the communication part in ajax httprequest response objects...the javascript n php are communicating...but wen i integrated the code into the extension, it din give output.
i heard that ajax wont work well in the backend in xul applications..something about xml render....is there any other way for carrying out this extension server communication...
a Mozilla Firefox extension which connects two or more people located at geographically distant areas, who happen to be browsing the same website simultaneously. It shows you other people who visit the same websites as you are.
The extension informs the server whenever the user clicks the EnableChat button to start a chat session.
The server retrieves from its database, the list of users who are currently online in that site and returns it.
The user can then click on any username for opening a chat session.
function useHttpResponse()
{
alert(xmlhttp.readyState);
if (xmlhttp.readyState==4 )
{
alert(xmlhttp.responseText);
}
}
verifyusernamepasswd():
var xml;
function verifyusernamepasswd()
{
var usernamebox=document.getElementById("some-text");
var passwordbox = document.getElementById("Userpassword");
var username=usernamebox.value;
var password=passwordbox.value;
alert(username);
xml=new XMLHttpRequest();
var url="loginvalidate.php";
var param="q="+username+"&p="+password;
function statechanged1()
{
if(xml.readyState==4 && xml.status==200)
alert(xml.responseText);
}
servercode.php
<?php
$q=$_GET["q"];
$con=mysql_connect("localhost","root","blaze");
if(!$con)
{die('could not connect to database'.mysql.error());
}
mysql_select_db("BLAZE",$con) or die("No such Db");
$result=mysql_query("SELECT * FROM USERURL WHERE url='php.com'");
if($result == null)
echo 'halla';
$con = mysql_connect("localhost","root","blaze");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$username=$_POST['username'];
$password=$_POST['password'];
var $false="false";
var $true="true";
mysql_select_db("BLAZE",$con);
$result=mysql_query("SELECT Userid,Password FROM USERTABLE WHERE Userid='$username'");
if($result==NULL)
echo $false;
else
{
$row=mysql_fetch_array($result)
if((strcmp($row["Userid"],$username)!=0)||(strcmp($row["Password"],$password)!=0))
{
echo $false;
}
else
echo $true;
}
?>
my problem is that i cant get the response of the php to the extension. there is proper connection between my javascript n php...for eg, i ran the javascript in html in /var/wwww here server code is n i got output. but wen i integrated it with the extension, i din get the response from php to the extension...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.