javascript + jquery 练习代码




  
  

    
        TODO supply a title
        
  
  
        
  
  
        
        <script>
            function my1()
            {
                document.getElementById("demo").innerHTML="my first JAVA_SCRIPT function";
            }
            
        </script>
        <script src="js/test.js"></script>
        <script src="js/jquery-2.2.3.min.js"></script>
    
    
        
  
  
TODO write content

我的web页面

一个段落













<script type="text/javascript"> var myCallBack1 = function(data){ console.log("this is myCallBack1"); console.log(data); } </script> <script type="text/javascript" src="http://121735.tunnel.2bdata.com/test/ajax.php?callback=myCallBack1"></script> <script type="text/javascript"> //生成js代码 var tempMyCallBack = myCallBack; var url = "http://121735.tunnel.2bdata.com/test/ajax.php?callback=tempMyCallBack"; // 创建script标签,设置其属性 var script = document.createElement('script'); script.setAttribute('src', url); document.getElementsByTagName('head')[0].appendChild(script); //console.log(document.getElementsByTagName('head')); </script> <script> document.write("

this is title

"); document.write("

this is page

"); function my2() { document.getElementById("demo").innerHTML="my second function"; } var person1 = Object.create(person); document.getElementById("demo").innerHTML = window.person.firstName; document.getElementById("demo").innerHTML = typeof(undefined); </script>
User Name:

City:

State:

Zip Code:

/* * 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; ?>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值