The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex
check this:
ReplyDeletethere is a simple quickstart tutorial.
http://www.365labs.net/cf_jquery/jquery_coldfusion_quickstart.htm
Some links I found are:
ReplyDeletehttp://blog.pengoworks.com/index.cfm/2011/3/3/Easy-AJAX-using-ColdFusion-jQuery-and-CFCs
http://blog.kukiel.net/2011/09/jquery-coldfusion-and-cfdump-into-div.html
http://tutorial43.learncf.com/
Help with return data using ColdFusion and jQuery Ajax
You can almost never go wrong reading these blogs for coldfusion
bennadel.com
coldfusionjedi.com
http://cflove.org/
I assume you have a fair knowledge of HTML. To accomplish the sort of thing you are asking, use this snippet:
ReplyDelete$.get("coldfusion-page.cfm",function(data){
$("#displaydiv").html(data);
});
$.get is a shorthand method that simply retrieves the given URL. The function() part that follows it is what is run when the request to the coldfusion page completes. All it does is put the data that came back into the HTML tag with an ID of "displaydiv".
It really doesn't get simpler than this.
You didn't elaborate on what you want to update on the client side. Forms are common, so if you have client side html form like:
ReplyDelete<input type="text" name="title">
<input type="text" name="date">
<input type="text" name="author">
You would generate and send a JSON string with coldfusion. The JSON string could look something like:
{"title" : "mytitle", "date" : "mydate", "author" : "myauthor"}
To update the data on the client side you would execute (coldfusion-page.cfm is the name of your server side ajax responder):
jsonOBJ = {};
$.ajax({
type: "GET",
url: "coldfusion-page.cfm",
cache: false,
success: function(data){
jsonOBJ = jQuery.parseJSON(data);
for (var key in jsonOBJ) {
$("input[name=" + key + "]").val(jsonOBJ[key]);
}
},
});
OR, If you just want to update a div or textarea like:
<div id="uniquedivname"></div>
you just send the html/text and replace the success function in the ajax call with:
success: function(data){
$("#uniquedivname").html(data);
},