Jump to content

Ajax calls using GET method causes bad characters in url


bambinou1980

Recommended Posts

Hello,
 
I have a quick question please.
 
I am trying to use Ajax for the first time.
 
My form has a delete button as:

<a class=\"btn btn-danger delete-button\" id=\"<?php echo $id; ?>\" role=\"button\">Delete</a>


 
When I initiate my ajax call:

<script type="text/javascript">
$(function() {
$(".delete-button").click(function(){
var element = $(this);
var del_id = element.attr("id");
var info = 'id=' + del_id;
if(confirm("Are you sure you want to delete this?"))
{
 $.ajax({
   type: "GET",
   url: "delete-record.php",
   data: info,
   success: function(){
 }
});
  $(this).parents(".show").animate({ backgroundColor: "#003" }, "slow")
  .animate({ opacity: "hide" }, "slow");
 }
return false;
});
});
</script>


 
 
I am getting a dirty url like this in the chrome XHR console:

XHR finished loading: GET "http:/websitename.com/admin/crud/payments/delete-record.php?id=%3C?php%20echo%20?%3E"


 
 
Any idea how to remedy to this please?
 
I tried urlencode($id); but it did not work.
 
 
Thank you,
 
Ben

Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.