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/..."

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

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来