$messages = $db->query("SELECT * FROM chatmessages ORDER BY datetime DESC, displayorderid DESC LIMIT 0,10");
while($message = $db->fetch_array($messages)) {
$oldmessages[] = $message['message'];
}
$oldmessages = array_reverse($oldmessages);
?>
<div id="chat">
<?php
for ($count = 0; $count < 9; $count++) {
echo $oldmessages[$count];
}
?>
<script language="javascript" type="text/javascript">
<!--
setInterval( "document.getElementById('chat').innerHTML='<NEW CONTENT OF #CHAT>'", 1000 );
-->
</script>
</div>
I'm trying to create a PHP chatroom script but I'm having a lot of trouble getting it to AutoRefresh
The content should automatically update to , how do you make it do that? I've been searching for almost an hour
You know that functions in a dll can be imported either by name or by ordinal index.
From wikipedia: For most Windows API functions only the names are preserved across different Windows releases; the ordinals are subject to change. Thus, one cannot reliably import Windows API functions by their ordinals.
My Question: I know these ordinals MAY CHANGE, but I want to know if they've ever ACTUALLY CHANGED. (Especially about kernel32 & user32 dlls)
Why I'm asking this? I heard some viruses do import win32 functions by ordinal. I want to catch them, and I want to know whether I can test for an ordinal number or not.
Thanks.
I have read some tutorials about creating an API and i wonder if XML-RPC and XML-RPC server in CodeIgniter are for creating this?
If yes, what are the benefits of using these classes rather than im just using regular class/methods/params to create my API interface.
This is what it said in the documentation:
Quite simply it is a way for two computers to communicate over the internet using XML. One computer, which we will call the client, sends an XML-RPC request to another computer, which we will call the server. Once the server receives and processes the request it will send back a response to the client.
I have a page with 5 buttons on top. I want the area below the buttons to contain an update panel that will display button 1's panel if they click button 1. If they click on Button 2, then I want button 2's update panel to replace the button 1 update panel. Each panel has stuff on it like check boxes and text boxes.
Is there a way to do this? Is there a more efficient way to do this?
I'm getting an error using Google Maps API V3 that I don't understand. My initial map displays just fine, but when I try to get directions, I get the following two errors:
Error: The value of the property 'GUnload' is null or undefined, not a Function object
Error: Unable to get value of the property 'setDirections': object is null or undefined
I'm not using GUnload anywhere, so I don't understand why I'm getting that error. As far as the second error is concerned, it's as if something is wrong with the Directions service.
Here is my code:
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
function initialize(address) {
directionsDisplay = new google.maps.DirectionsRenderer();
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(42.733963, -84.565501);
var mapOptions = {
center: latlng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
directionsDisplay.setMap(map);
}
function getDirections(start, end) {
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
} else {
alert("Directions cannot be displayed for the following reason: " + status);
}
});
}
I'm not very savvy with javascript, so I could have made some sort of error there. I appreciate any help I can get.
The googleAPI example shows that you should have the javascript within the head tag but I am using perl module CGI and in there they suggest that you use "print header;" instead of writting out your headers explicitly.
So if I want to use the perl CGI module and the googleAPI javascript what is the correct way to do this?
I tried writing out the header explicitly but It seemed like the perl module really wanted me to use the header method. It seems like this would be a common use case but I looked around the web for some examples of this and I could not find one. Any help would be appreciated.
Hi, I have been monitoring the parameters a website receives when a file is uploaded (via an input type="file"). Surprisingly, the parameter and its value were looking like this :
parameter: upfile
value: filename="this is the name of the uploaded file.png" Content-type: image/x-png
Now in this POST request to the server page, the file name and its type is passed into a parameter, but what about the path to that filename? Where is that path stored so that the server page can upload the file at the good location?
Also, I would like to know if it would be possible by any way to specify a path, NOT to the input type="file" since its impossible, but to the server (though this question probably depends a lot on how the server-side page is scripted).
Thank you for your answers.
I want to use Wicket to build an application, but I have some designers that would like to write/maintain the javascript, and they basically expect 1 JS-segment per page, and a global JS-file.
I think the most natural way to add javascript in wicket is to add it per component (not per page), which would create problems for those designers (fractioned javascript, and having to write it in java-files). Is there a better way to solve this?
(of course, I expect things to work after a partial refresh.)
And a second (related) thing they'd like (and I'd like actually) is the possibility to request information in JSON-format through a static link , is this possible in Wicket?
I'm creating a form that collects standard information about customers. When the user hits save, I would like to create a .txt file that would be used to later retrieve all of the data collected from customers. I'm using DataTables which is a jQuery plugin to display the data. The .txt file would be formatted to be saved as such:
{ "aaData": [
["client 1 name","address","city","state","zip"],
["client 2 name","address","city","state","zip"],
["client 3 name","address","city","state","zip"],
...
["client x name","address","city","state","zip"]
] }
Where "aaData": is used by DataTables. This is going to part of an iPhone app, so the data source has to be very small and not reliant on a constant connection to a server, so, essentially, a client-side data source. The .txt file has to also be updated when edited and saved, and then replaced every time it is downloaded.
Having a problem where the form submits before the validateUsername function has a chance to complete the username check on the server-side.
How do I submit the form only after the validateUsername function completes?
Hope this is clear...
form.submit(function(){
if (validateUsername() & validateEmail() & validatePassword()) {
return true;
} else {
return false;
}
});
function validateUsername(){
usernameInfo.addClass("sign_up_drill");
usernameInfo.text("checking...");
var b = username.val();
var filter = /^[a-zA-Z0-9_]+$/;
$.post("../username_check.php",{su_username:username.val()},function(data) {
if (data=='yes') {
username.addClass("error");
usernameInfo.text("sorry, that one's taken");
usernameInfo.addClass("error");
return false;
} else if (!filter.test(b)) {
username.addClass("error");
usernameInfo.text("no funny characters please");
usernameInfo.addClass("error");
return false;
} else {
username.removeClass("error");
usernameInfo.text("ok");
usernameInfo.removeClass("error");
return true;
}
});
}
I am trying to click on an image and change it to another image through jquery.
When i step through the below code, on the serverside, the controller action fires and on the client side, i can see the correct html return in firebug watch window but the image doesn't change at all. any idea why this div is not updating?
original div:
<div class="inlineDiv" toggle="off" id="22"><img src="../../images/vote-favorite-off1.png" border="0"></div>
jquery code:
$(document).ready(function() {
$('div.inlineDiv').live('click', function() {
var id = $(this).attr("id");
var toggle = $(this).attr("toggle");
var url = '/Tracker/Update?id=' + id + '&toggle=' + toggle;
$.get(url, function(data) {
$(this).html(data);
});
});
});
controller action:
public ActionResult Update(int id, string toggle)
{
if (toggle == "off")
{
return Content("<img src='../../images/vote-favorite-on1.png' border=0'>");
}
return Content("<img src='../../images/vote-favorite-off1.png' border=0'>");
}
Just curious if I am overlooking something simple here. I have deployed the remote_form_for in the show.html.erb code before to render comments on a post (project in this case) without a problem. I have moved this code to the index view and seems to degrade to the normal form_for action (page refresh). I am not getting any javascript errors so not sure what is wrong here. Here is my code:
index.html.erb
<% remote_form_for [project, Comment.new] do |f| %>
<p>
<%= f.label :body, "New Comment" %><br/>
<%= f.text_area (:body, :class => "textarea") %>
</p>
<p>
<%= f.label :name, "Name" %> (Required)<br/>
<%= f.text_field (:name, :class => "textfield") %>
</p>
<p>
<%= f.label :email, "Email" %> (Required but will not be displayed)<br/>
<%= f.text_field (:email, :class => "textfield") %>
</p>
<p><%= f.submit "Add Comment" %></p>
<% end %>
CommentsController#create
def create
@project = Project.find(params[:project_id])
@comment = @project.comments.create!(params[:comment])
respond_to do |format|
format.html { redirect_to projects_path }
format.js
end
end
/views/comments/create.js.rjs
page.insert_html :bottom, :commentwrapper, :partial => @comment
page[@comment].visual_effect :highlight
page[:new_comment].reset
page.replace_html :notice, flash[:notice]
flash.discard
/views/comments/_comment.html.erb
<% div_for comment do %>
<div id="commentwrapper">
<% if admin? %>
<%=link_to_remote "X", :url => [@project, comment], :method => :delete %>
<% end %>
<%= h(comment.body) %><br/><br/>
Posted <%= time_ago_in_words(comment.created_at) %> ago by <%= h(comment.name) %>
<% if admin? %>
| <%= h(comment.email) %>
<% end %></div>
<% end %>
info = {'phone_number': '123456', 'personal_detail': {'foo':foo, 'bar':bar}, 'is_active': 1, 'document_detail': {'baz':baz, 'saz':saz}, 'is_admin': 1, 'email': '[email protected]'}
return HttpResponse(simplejson.dumps({'success':'True', 'result':info}), mimetype='application/javascript')
if(data["success"] === "True") {
alert(data[**here I want to display personal_detail and document_details**]);
}
How can I do this?
I have basically this on a page:
<script type="text/javascript">
function refresh_context() {
$("#ajax-context").html("Searching...");
$.get("/ajax/ldap_search.php", {cn: $("#username").val()}, function(xml) {
$("#ajax-context").html($("display", xml).text());
$("#context").val($("context", xml).text());
}, 'xml');
}
$(document).ready(function() {
$("#username").blur(refresh_context);
});
</script>
<input type="text" name="username" id="username" maxlength="255" value="" />
<input type="hidden" name="context" id="context" value=""/>
<div id="ajax-context"></div>
What it should do (and does fine on Firefox) is when you type a username in to the #username field, it will run /ajax/ldap_search.php?cn=$username, which searches our company's ldap for the username and returns it's raw context and a formatted version of the context like this:
<result>
<display>Staff -> Accounting -> John Smith</display>
<context>cn=jsmith,ou=Accounting,ou=Staff,ou=Users,o=MyOrg</context>
</result>
The formatted version (display) goes to the div #ajax-context and goes to the hidden input #context. (Also, the - are actually - "& g t ;" (without spaces)).
However, on IE the div stays stuck on "Searching..." and the hidden input value stays blank.
I've tried both .get and .post and neither work. I'm sure it's failing on the .get because if I try this, I don't even get the alert:
$.get("/ajax/ldap_search.php", {cn: $("#username").val()}, function() {
alert("Check");
});
Also, IE doesn't give me any script errors.
Edit: Added "$(document).ready(function() {", the .blur was already in it in my code, but I forgot to include that in my post.
Edit 2: The request is being sent and apache2 is receiving it:
10.135.128.96 - - [01/May/2009:10:04:27 -0500] "GET /ajax/ldap_search.php?cn=i_typed_this_in_IE HTTP/1.1" 200 69
I would like to load an XML file every 30 seconds and display its contents inside an HTML page.
So far I know how to load the file, but I don't know how to automatically refresh it and display its updated contents. It would also be great if it did some error checking and if it displayed error.png image when it's not able to load data.xml file.
Here is my code:
<head>
<script>
window.XMLHttpRequest
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.open("GET", "data.xml", false);
xmlhttp.send();
loadXMLDoc = xmlhttp.responseXML;
f = loadXMLDoc.getElementsByTagName("foo")
function buildBar(i)
{
qux = (f[i].getElementsByTagName("qux")[0].childNodes[0].nodeValue);
document.getElementById("displayBar").innerHTML = qux;
}
</script>
</head>
<body>
<script>
document.write("<ul>");
for (var i = 0; i < f.length; i++)
{
document.write("<li onclick='buildBar(" + i + ")'>");
document.write(f[i].getElementsByTagName("bar")[0].childNodes[0].nodeValue);
document.write("</li>");
}
document.write("</ul>");
</script>
<div id="displayBar">
</div>
</body>
After searching the internet for a few hours I found many examples on how to do this, but I didn't know how to implement it in my particular case. I am not a programmer, so please be kind.
I would really appriciate any help. It would mean a lot.
Hello! I'm using jQuery Form (http://jquery.malsup.com/form/) to get send data to a form - is there a way I can then, without refresh, put the results page that's generated by the form into a div on the page?
Any advice appreciated!
I've found that on Google support driving navigation on latest Android. http://www.google.com/mobile/navigation/index.html
But, I can't find any kinds of API set to provide those kinds of functions. Is there navigation support API? or isn't it released yet?
I can't understand why it's not included on Ginger bread version. They said that Nexus S already support Driving navigation.
Do you have any information about this issue? Please let me know. Thanks.
I'm developing a webpage and I would just like to make something more user friendly. I have a functional Google Maps api v3 and an address search bar. Currently, I have to use the mouse to select search to initialize the geocoding function. How can I make the map return a placemark by hitting the enter button on my keyboard? I just want to make it as user-friendly as possible.
Here is the javascript and div, respectively, I created for the address bar:
var geocoder;
function initialize() {
geocoder = new google.maps.Geocoder ();
function codeAddress () {
var address = document.getElementById ("address").value;
geocoder.geocode ( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results [0].geometry.location);
marker.setPosition(results [0].geometry.location);
map.setZoom(14);
}
else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
<div id="geocoder">
<input id="address" type="textbox" value="">
<input type="button" value="Search" onclick="codeAddress()">
</div>
Thank you in advance for your help
Here is my jQuery code:
$.get('/Home/GetList', function(data) {
debugger;
$('#myMultiSelect').val(values);
});
Here is my controller code:
public ActionResult GetList(int id)
{
int[] bodyParts = _repository.GetList(id);
//how do i return this as an array back to javascript ??
}
if I have the GetList function return an array of integers, how do I return this to the jQuery function?
Hey! I'm teaching myself Ruby, and have been stuck on this for a couple days:
I'm currently using MooTools-1.3-compat and Rails 3.
I'd like to replace one button (called "Follow") with another (called "Unfollow") as soon as someone clicks on it. I'm using :remote = true and have a file ending in .js.erb that's being called...I just need help figuring out what goes in this .js file
The "Follow" button is in a div with id="follow_form", but there are many buttons on the page, and they all have an id = "follow_form"...i.e. $("follow_form").set(...) replaces the first element and that's not correct. I need help replacing the button that made the call.
I looked at this tutorial, but the line below doesn't work for me. Could it be because I'm using MooTools instead of Prototype?
$("follow_form").update("<%= escape_javascript(render('users/unfollow')) %")
ps. This is what I have so far, and this works:
in app/views/shared:
<%= form_for current_user.subscriptions.build(:event => @event), :remote => true do |f| %>
<div><%= f.hidden_field :event %></div>
<div class="actions"><%= f.submit "Follow" %></div>
<% end %>
in app/views/events/create.js.erb
alert("follow!"); //Temporary...this is what I'm trying to replace
*in app/controllers/subscriptions_controller.rb*
def create
@subscription = current_user.subscriptions.build(params[:subscription])
@subscription.save
respond_to do |format|
format.html { redirect_to(..) }
format.js {render :layout}
end
Any help would be greatly, greatly appreciated!
$messages = $db->query("SELECT * FROM chatmessages ORDER BY datetime DESC, displayorderid DESC LIMIT 0,10");
while($message = $db->fetch_array($messages)) {
$oldmessages[] = $message['message'];
}
$oldmessages = array_reverse($oldmessages);
?>
<div id="chat">
<?php
for ($count = 0; $count < 9; $count++) {
echo $oldmessages[$count];
}
?>
<script language="javascript" type="text/javascript">
<!--
setInterval( "document.getElementById('chat').innerHTML='<NEW CONTENT OF #CHAT>'", 1000 );
-->
</script>
</div>
I'm trying to create a PHP chatroom script but I'm having a lot of trouble getting it to AutoRefresh
The content should automatically update to , how do you make it do that? I've been searching for almost an hour
Basically what I'm doing is checking for the existence of an object, if it's not found, the script will try to load the source file using getScript. I only want to check this once though then return true or false to the function that calls fetch()
fetch:function(obj){
...
isReady = false;
$.getScript(obj.srcFile,function(){
isReady=true;
warn("was able to load object "+key);
});
return isReady;
}
but return kicks in before the script loads =/
later the script is loaded but the function returned false.
This is the beauty of asynchronous I suppose...
What's the best way to handle this... Maybe I could check again at some other point if the object exists?
Or maybe there's a better way to do this where I dont have to potentially lock the browser?