douyunjiaok300404 2015-01-21 08:39
浏览 82
已采纳

Cookie未在Internet Explorer中设置,给出错误

I have been using the below code, to create a cookie, this works completely fine in all the browsers except INTERNET EXPLORER.. it gives the below error when i click on create cookie button.

Error

Message: '$' is undefined
Line: 4
Char: 2
Code: 0
URI: http://localhost/js/scripts.js

Code

<p>Click on the <strong>Set Cookie</strong> button below to create the testing cookie.</p><br>
            <button style="color: black" input type="button" onclick="set_cookie(<?php echo "'".$set_cookie_url."'" ?> );" <?php if(isset($_COOKIE["cookieid"])) { ?> Disabled <?php } ?>value='Set Cookie'><b>Set cookie</b></button>

JS Code

function set_cookie(url){
    $.get( url, { cookieid: "628929", projectid: "1" }, set_cookie_complete);
    $('body').modal('show') ;
}
function set_cookie_complete(){
    location.reload();  
}

function unset_cookie(url){
    $.get( url, { cookieid: "628929", projectid: "1" }, unset_cookie_complete);
    $('body').modal('show') ;
}
function unset_cookie_complete(){
    location.reload();  
}

can anybody help me to get rid of this error and set the cookie

  • 写回答

1条回答 默认 最新

  • douxi4287 2015-01-21 09:30
    关注

    For IE8 and older you cannot use jQuery 2.x

    Change your link to version 1.11.x. For such simple code you use there should be no differences.

    <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
    
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    

    Note: using '//' on the start of the URL helps browser to decide how to process it and allow to use both HTTP or HTTPS. Not using it may result in url "http://your.server.com/ajax.googleapis.com/ajax/..."

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决