This probably helps: http://www.mikedoesweb.com/2012/creating-your-own-javascript-library/
This is a minimum javascript library whose grammar is very similar to jQuery: _('id').function(). It helps to understand how jQuery is written from scratch.
I think I can start writing a javascript library similar to jQuery now :).
Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts
Wednesday, November 5, 2014
Tuesday, October 21, 2014
jQuery 1.8 update on ajax call
jQuery ajax call uses different syntax since version 1.8 [1].
Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8 (but still works in 1.9.1). To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.
Get html in jQuery before 1.8:
$.ajax({
url: 'test.html',
dataType: 'html',
success: function (data, textStatus, xhr)
{
console.log(data);
},
error: function (xhr, textStatus, errorThrown)
{
console.log('error: '+textStatus);
}
});
The code above still works in 1.8. But the code below no longer works in 1.8:
$.post("get_news.php", { id: id }, function(data, status) {
if (status == "success") {
if ( data != '' ) {
o.innerHTML = data;
}
return 1;
} else {
return 1; // ok
}
}, 5);
Get html in jQuery since 1.8:
// cache: false is used to fetch the latest version
$.ajax({
type: 'POST',
url: "test.html",
data: { id: id },
dataType: 'html',
cache: false
})
.done(function(data, textStatus, jqXHR)
{
console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown)
{
console.log('error: '+textStatus);
});
[1] http://www.sitepoint.com/ajax-jquery-1-8/
Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8 (but still works in 1.9.1). To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.
Get html in jQuery before 1.8:
$.ajax({
url: 'test.html',
dataType: 'html',
success: function (data, textStatus, xhr)
{
console.log(data);
},
error: function (xhr, textStatus, errorThrown)
{
console.log('error: '+textStatus);
}
});
The code above still works in 1.8. But the code below no longer works in 1.8:
$.post("get_news.php", { id: id }, function(data, status) {
if (status == "success") {
if ( data != '' ) {
o.innerHTML = data;
}
return 1;
} else {
return 1; // ok
}
}, 5);
Get html in jQuery since 1.8:
// cache: false is used to fetch the latest version
$.ajax({
type: 'POST',
url: "test.html",
data: { id: id },
dataType: 'html',
cache: false
})
.done(function(data, textStatus, jqXHR)
{
console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown)
{
console.log('error: '+textStatus);
});
[1] http://www.sitepoint.com/ajax-jquery-1-8/
Wednesday, April 18, 2012
"Same Domain Policy" limitation of jQuery
The same domain policy prevents javascripts hosted on one domain from accessing data from a remote domain. This is for security purpose. So when use jQuery, you can not directly access a web service from a remote server.
The solution is to create a serverside script (for example, in php, as shown below) on your domain, which will serve as a proxy, get the data from the remote domain, and then output it. For example:
<?php
readfile('http://remote_server.com/service?param=' . urlencode($_GET['param']);
?>
[1] Getting data from remote URL using jquery
[2] Cross-domain requests with jQuery
The solution is to create a serverside script (for example, in php, as shown below) on your domain, which will serve as a proxy, get the data from the remote domain, and then output it. For example:
<?php
readfile('http://remote_server.com/service?param=' . urlencode($_GET['param']);
?>
[1] Getting data from remote URL using jquery
[2] Cross-domain requests with jQuery
Monday, June 6, 2011
jQuery, Charting
http://jquery.com/
flot - Javascript plotting for jQuery : draws on the canvas element (For IE version earlier than 9, needs excanvas JavaScript emulation helper and canvas-text). Purposes are easy use, attractive look, and interactive features.
Google charts - This is actually closed source. The JavaScript is compacted, and loads libraries dynamically at runtime.
用于图片处理的10个超级jQuery插件
Comparison: Javascript框架和jQuery
flot - Javascript plotting for jQuery : draws on the canvas element (For IE version earlier than 9, needs excanvas JavaScript emulation helper and canvas-text). Purposes are easy use, attractive look, and interactive features.
Google charts - This is actually closed source. The JavaScript is compacted, and loads libraries dynamically at runtime.
用于图片处理的10个超级jQuery插件
Comparison: Javascript框架和jQuery
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2026
(36)
-
▼
June
(19)
- C10K to C10M: from thread-per-connection model to ...
- Benchmark server performance
- Application server for php, python, java, node.js,...
- Application server for C++, Go and Rust
- Nginx as reverse proxy and load balancer
- Infrastructure running: nginx, apache, php, python...
- Flow chart of nginx+apache+uvcorn infrastructure
- Flow chart of apache+uvcorn infrastructure
- Uvicorn and Gunicorn
- What's deadsnakes PPA
- What's the optional lsb-core package
- Codex known logging bug
- Daemonsize a service
- Train text to image model, to generate images of c...
- Train a model based on OpenAI API
- Open port 8080 for WebSocket
- Add websocket support on Bluehost Ubuntu VPS for D...
- Install Claude Code on ubuntu VPS of Bluehost
- Install PostgreSQL on Mac
-
▼
June
(19)