jQuery stopped working with PHP -
i have written code jquery session, etc. happens when click text link should come "success"
but when there's no data works, when put in data , fix it, code stops working completely.
$(function() { $(".open").click(function() { var status = "open"; var ticketid = "<?php echo $_get['id']; ?>"; var username = "<?php echo $_session['mm_username']; ?>"; var datastring = 'status=' + status + 'id=' + ticketid + 'username=' + username; if(status==='' || ticketid==='' || username==='' || datastring==='') { $('.success').fadeout(200).hide(); $('.error').fadeout(200).show(); } else { $.ajax({ type: "post", url: "core/ticketdata.php", data: datastring, success: function(result){ $('.success').fadein(200).show(); $('.error').fadeout(200).hide(); } }); } return false; }); });
this view source
$(function() { $(".open").click(function() { var status = "open"; var datastring = 'status='+status; if(status==='') { $('.success').fadeout(200).hide(); $('.error').fadeout(200).show(); } else { $.ajax({ type: "post", url: "core/ticketdata.php?id=772&username=nomansland", data: datastring, success: function(result){ $('.success').fadein(200).show(); $('.error').fadeout(200).hide(); } }); } return false; }); });
but when php empty works completely, when it's there stops. have tried echo & print.
any ideas?
updated
ok have worked on this, alerts work when you: click it, check variables, go through else, when hit $.ajax({ wont alert.
<script> $(function() { $(".open").click(function() { var status = "open"; var ticketid = "<?php echo $_get['id']; ?>"; var username = "<?php echo $_session['mm_username']; ?>"; var datastring = 'status=' + status + '&id=' + ticketid + '&username=' + username; if(status==='' || ticketid==='' || username==='' || datastring==='') { $('.success').fadeout(200).hide(); $('.error').fadeout(200).show(); } else { datastring = { 'status' = status, 'id' = ticketid 'username' = username }; $.ajax({ type: "post", url: "core/ticketdata.php", data: datastring, success: function(result){ $('.success').fadein(200).show(); $('.error').fadeout(200).hide(); } }); } return false; }); });
updated
removed site, issue has been resolved.
you aren't concatenating correctly, missing &
s in data
, , that's why fails:
datastring = 'status=' + status + '&id=' + ticketid + '&username=' + username; //---------------------------------^-------------------^
Comments
Post a Comment