Jump to content

PHP AJAX issue with IE


james182

Recommended Posts

ok here is my code it works great in Firefox but not at all in IE.

 

The code should post the id of a item via ajax post method.

 

Javascript:

$(document).ready(function(){
    $('a.addFavs').click(function(){
        var favData = $(this).attr('id');

        $.post("path/to/addFav.php",{ send_favData: favData },
            function(data){
                $('#msg').html(data.returnValue);
            }, "json");		
});

 

 

addFav.php

<?php

include_once("config.php");
//addFavourite($_GET['send_favData']);

// TESTING
if (isset($_POST['send_favData'])){
    $value = $_POST['send_favData']; 
}else{
    $value = "No Data";
}

echo json_encode(array("returnValue"=>"Value Returned: ".$value), true);
?>

 

Function.php

function addFavourite($favData){
global $link;

$data = explode(",", $favData);

$query = "INSERT INTO tbl_favourites (fav_id, fav_user_id, fav_item_id, fav_cat_id, fav_section_id) VALUES (NULL, '$data[0]', '$data[1]', '$data[2]', '$data[3]')";
$result = mysql_query($query, $link) or die("add Favourites fatal error: ".mysql_error());
if($result){
	echo "<p>Successful!</p>";
}else{
	echo "<p>Failed!</p>";
}

}

Link to comment
https://forums.phpfreaks.com/topic/190195-php-ajax-issue-with-ie/
Share on other sites

I fail to see how this could be PHP related. It is most likely on the Client side with the javascript / AJAX and as such I doubt the error is in the code provided. Moving to the AJAX forms, you may want to provide the HTML that this code is being used on.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.