JQuery / Ajax call - it does not work on IE7

I am creating a jQuery function that (at the moment) calls the function dynamically and prints it with a warning. with firefox, chrome: it works! when I try to use IE7 (first time), it fails. If I reload the page (F5) and repeat, it will work! o_o

I fully understand why this is happening. On my old website, I used the jquery-1.3.2.min.js library. On this I use jquery-1.4.2.js, and in fact it does not work. So what? Error in this new version?

amuses

EDIT

valid features (with Bryan Waters suggestions):

// html page
<a href="#" onClick="pmNew('1');return false">prova</a>    

// javascript page
function pmNew(mexid) {
    var time = new Date;
    $.ajax({
        type: 'POST',
        cache: false,
        url: './asynch/asynchf.php' + '?dummy=' + time.getTime(),
        data: 'mexid='+escape(mexid)+'&id=pmnew',
        success: function(msg) {
            alert(msg);
        }
    });
    return false;
}

// ajax.php
if($_POST['id']=="pmnew") {
    echo "please, i will just print this";
}

Fiddler: http://localhost/website, fiddler . http://ipv4.fiddler/website, , ajax . , , . mah... , ...

+3
7

- Fiddler , HTML-, ajax, - 200 404 - .

IE . . javascript , URL , .

+2

ok, , , , , jquery .

, ,

<a class="lblueb" href="./asynch/asynchf.php?mexid=<?$value?>"><?=value?></a>

javascript document.ready, , :

$(function(){

});

click ready mexid href, pmNew :

$(".lblueb").click(function(e){

  e.preventDefault();

  //your query string will be in parts[1];
  parts = $(this).attr("href").split("?");
  //your mexid will be in mexid[1]
  mexid = $parts[1].split("="); 

  //call your function with mexid[1] as the parameter
  pmNew(mexid[1]);

});

:

<script type="text/javascript">

function pmNew(mexid) {
    $.ajax({
        type: "POST",
        url: "./asynch/asynchf.php",
        data: "mexid="+mexid+"&id=pmnew",
        success: function(msg){
            $("#pmuser").html('<a class="bmenu" href="./index.php?status=usermain">PANEL ('+msg+')</a>');
        }
    });
}

//document.ready function
$(function(){

  $(".lblueb").click(function(e){

    //prefent the default action from occuring   
    e.preventDefault();

    //your query string will be in parts[1];
    parts = $(this).attr("href").split("?");

    //your mexid will be in mexid[1]
    mexid = $parts[1].split("="); 

    //call your function with mexid[1] as the parameter
    pmNew(mexid[1]);

  });

});

</script>
+2

, SQL. , userd userid?

Gaby , SQL- . , PDO, SQL-, . , ($ sql) execute ($ sql), , .

0

, script - script. , , sql-.

, , html , .

sql .

- , ... vars , -. .

, , .... , , : html :

<a class="lblueb" href="#" onclick="return pmNew('<?php echo $value; ?>')"><?php echo $value; ?></a>

JS :

function pmNew(mexid) {
    $.ajax({
        type: 'POST',
        cache: false,
        url: './asynch/asynchf.php',
        data: 'mexid=' + escape(mexid) + '&id=pmnew',
        success: function(msg) {
            $('#pmuser').html('<a class="bmenu" href="./index.php?status=usermain">PANEL (' + msg + ')</a>');
        }
    });
    return false;
}

, IE - . /

0

"", .

function pmNew(mexid) {
    $.post("./asynch/asynchf.php", {mexid: mexid, id: "pmnew"},
        function(msg) {
            $("#pmuser").html('<a class="bmenu" href="./index.php?status=usermain">PANEL ('+msg+')</a>');
        }
    });
}
0

, , DOM, DOCTYPE.

I had a similar problem with Chrome, FF and Safari, everything worked fine, but found that the ajax result was broken in IE. Make sure you don't have extra divs or intervals as a result of ajax that break your markup.

0
source

Source: https://habr.com/ru/post/1754041/


All Articles