Knowledge point 1: What is the difference between HttpResponse and jsonresponse?
HttpResponse (Json.dumps (dictionary or list))
Jsonresponse (only a dictionary, not a list!) ), if you want to write the list, then add the attribute safe------>jsonresponse (list, safe=false)
jquery extensions are available in two ways:
Way One:
Jquery.extend ({ "xxx": function (args) { alert (args) }}) $.xxx (666)
Way two:
Jquery.fn.extend ({
"XXX": function (args) {
Contains the statement about this;
}
})
$ ("#id"). XXX (666) //This call is not jquery, but a specific tag, and the above refers to the tag of the call.
The use of self-executing functions:
(The function (JQ) {
Function F1 () {}
function F2 () {}
...
Jq.extend ({
"XXX". function (args) {}
})
}) (JQuery)
$.XXX (666)
This section focuses on:
1. Because JS does not have a format function in Python, then you need to write it yourself.
Because JS has a string replace the built-in function replace, use: String S.replace ("s substring", "to do the substitution of the string"), in fact, the formatting of the string is the essence of the string substitution.
var name = ' Alexegon '= name.replace (' e ', ' EEE ');
Result: New_name:aleeexegon, will only replace the first place!!!
Mode 2:
The first parameter of the Repalce is written as a regular expression, and the format is/regular expression/, if this is also the first place to replace, if you add g later, it is replaced by all conforming regular expression specification.
That is, new_name = name.replace (/Regular expression/g, ' EEE '), the result is: Aleeexeeegon.
Mode 3:
The second parameter of replace can also be an anonymous function and must have a return value, then the return value replaces the string that the regular expression matches successfully.
Name.replace (/a/,function (k,v) {})
where k----> refers to a successful string, V-----> refers to the position of this string
Note: The value of k,v can have multiple groups.
Formatting:
Name = "Sfsdcdsvd{xxx},vfes{uuuu}"
Kwargs = {"xxx": ' Alex ', ' uuuu ': ' 18 '}
Need to write a format function to make Name.format (Kwargs)
JS Prototype: Adds a method to the class, which can be called later, and automatically calls the following function when the string object calls format.
String.prototype.format = function (Kwargs) {
Return This.replace (/\{(/w+) \}/,function (k,v) {
return KWARGS[V]
});
}
Name.format (Kwargs);
JS defines the class:
function Foo (name,age) {
THIS.name = name;
This.age = age;
}
Foo.prototype.func = function () {
This ...
}
obj = new Foo (' Egon ', 19);
Obj.func ()
JS Fast completion of database data display 2