Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is function ajax call

function updateProduct(typeopts){
$.ajax({

type: "POST",
url: "include/submit.php",
dataType : 'json',
data: {filterTypeOpts: typeopts,child: 179},
cache: false,
success: function(data){

$('#disp').html(makeTable(data));

}

});
}


on submit.php page


echo $typeopts = isset($_POST['filterTypeOpts'])? $_POST['filterTypeOpts'] : array('');
echo $ctemp = $_POST['child'];
Posted

1 solution

Rewrite your function as
JavaScript
function updateProduct(typeopts){
    $.ajax({
        type: "POST",
        url: "include/submit.php",
        dataType : 'json',
        data: {filterTypeOpts: typeopts,child: 179},
        cache: false,
        success: function(data){
            $('#disp').html(makeTable(data));

        }
        error: function(err){
            $("#error_window").html(err.responseText);
        }
    });
}


Also make a div with id error_window; This will help you to understand, what went wrong
finally
PHP
//i am guessing $_POST['filterTypeOpts'] is an array. Your php is suppose to screw up here. 
echo $typeopts = isset($_POST['filterTypeOpts'])? $_POST['filterTypeOpts'] : array('');


Another possible error you would face is, you are echoing or printing non JSON text. Even if your php works properly and your server response with status code 200 but yet your JQuery will through the result in error status.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900