TODO write content
我的web页面
一个段落
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var xmlhttp;
var count = 0;
var person = {
firstName:"John",
lastName:"Doe",
age:50,
eyeColor:"blue",
fullName : function() {
console.log( this.firstName + " " + this.lastName );
}
};
function fullName()
{
person.fullName();
}
function test1()
{
document.getElementById("demo").innerHTML = "extern function";
}
function windowAlter()
{
window.alert(5+6);
}
function writeDate()
{
// document.write(Date());
document.getElementById("demo").innerHTML = Date();
consoleLog();
}
function consoleLog()
{
var a = 1;
var b = 2;
var c = a + "volvo";
console.log(c);
}
function onMouseOver()
{
document.getElementById("demo").innerHTML = "onMouseOver";
}
function onMouseOut()
{
document.getElementById("demo").innerHTML = "onMouseOut";
}
function onMouseEnter()
{
document.getElementById("demo").innerHTML = "onMouseEnter";
}
function onMouseDown()
{
document.getElementById("demo").innerHTML = "onMouseDown";
}
//xmlHttp请求
function xmlHttpReq(url)
{
xmlhttp=null;
xmlhttp = new XMLHttpRequest();
if (xmlhttp!=null){
xmlhttp.onreadystatechange=xmlHttpRes;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
}
function xmlHttpRes()
{
// xmlHttp返回处理
if (xmlhttp.readyState==4){
// 4 = "loaded"
if (xmlhttp.status==200){
// 200 = "OK"
console.log("this is xmlHttpRes");
console.log(xmlhttp.responseText);
}
}
}
//回调函数
function myCallBack(data)
{
console.log("this is myCallBack");
console.log(data);
}
//ajax 和 getJSON 跨域请求方式
function parseMyJson()
{
//ajax 请求方式 回调函数参数由jquery参数生成,请求成功回调函数会调用success函数
$.ajax({
//url: "test.php?callback=?",
url: "http://121735.tunnel.2bdata.com/test/ajax.php",
type: "GET",
dataType: "jsonp",
jsonp:"callback",
data:{ "phone":"131621", "passwd":"123456"},
success: function(data){
console.log("this is ajax callback success");
console.log(data);
},
error: function(){
alert("fail");
}
});
//getJSON 请求方式 回调函数参数由jquery参数生成,请求成功回调函数会调用写好的function函数
$.getJSON("http://121735.tunnel.2bdata.com/test/ajax.php?callback=?",
{
"phone":"131621",
"passwd":"123456"
},
function(data){
console.log("this is getJSON callback success");
console.log(data);
});
}1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
$result=json_encode($arr);
//var_dump($_GET['callback']);
if( isset($_GET['callback']) ){
$called=$_GET['callback'];
echo $called . "({$result})";
}else{
echo "({$result})";
}
//echo $result;
?>