manix Posted August 15, 2011 Share Posted August 15, 2011 Erm okay this is not working properly, it sends the request, it handles the response but it's not passing the data? var aldata = 'id='+ 16 + '&comment=' + ($('#comment').val()) + '&startfrom=' + <?php echo $lastid;?>; $.ajax({ url: "usercomments.php", type: "POST", contentType: 'text/html; charset=windows-1251', data: aldata, success: function(returned){ $('#comments').html(returned+$('#comments').html()).show(); } }); in my PHP file I use $_POST['id'] and it says unidentified index 'id' ? I tried both the above example and aldata = "{'id':'"+ u_i +"','comment':'"+ ($('#comment').val()) +"','startfrom':'"+<?php echo $lastid;?>+"'}"; Same result.. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 15, 2011 Share Posted August 15, 2011 The best way to track these sorts of requests is to look at the console in Firebug. It'll show the request, the response and all headers sent plus errors received etc. You should put your data like you have in the second example, but not surround it in quotes like you have. You want it to be an object, not a string. Here is how it should look: $.ajax({ url: "usercomments.php", type: "POST", contentType: 'text/html; charset=windows-1251', data: { id: 16, comment: $('#comment').val(), startfrom: <?php echo $lastid; ?> }, success: function(returned){ $('#comments').html(returned+$('#comments').html()).show(); } }); Quote Link to comment Share on other sites More sharing options...
manix Posted August 15, 2011 Author Share Posted August 15, 2011 erm.. okay I just installed firebug and I am looking at the console, there are no errors :? It's sending all the data (in the post tab) I can't understand where the problem is Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.