1

I'm new to this, but I have tried for 2 hours on every page and example possible....

<script type="text/javascript" src="jquery-1.10.1.min"></script>
<script type="text/javascript">
function UpdateCart(itemid,todo)  
   {
   $.get("updatecart.php?itemnumber=" + itemid + "&todo=" + todo);
   }
</script>

I have an html element to trigger the above code on click:

<a href='javascript:void(0)' onclick='UpdateCart("60813","remove");'>Remove Item</a>

For the life of me, i can't get it to work... When I try it with regular ajax coding, it works, but i'm trying minimize code. also, I have tested the updatecart.php manually with url variables and it works fine and does what it should.

5
  • code for html exlement: <a href='javascript:void(0)' onclick='UpdateCart("60813","remove");'>Remove Item</a> Commented Jun 19, 2013 at 22:44
  • don't know why it wont let me post that code in the original question.... Commented Jun 19, 2013 at 22:44
  • you should get the response and status to see what goes wrong Commented Jun 19, 2013 at 22:48
  • 4
    should your script include have the js at the end of jquery-1.10.1.min Commented Jun 19, 2013 at 22:52
  • 2
    @Orangepill OMG OMG THAT WAS IT!! man ... i hate programming sometimes. the little stupid stuff ALWAYS gets me! Commented Jun 19, 2013 at 23:24

2 Answers 2

2

It looks like you're getting the contents of the page, but then not doing anything with the ajax response. Did you mean to do something like this?

$.get("updatecart.php?itemnumber=" + itemid + "&todo=" + todo, function(resp){
   $('#target').html(resp);
});
Sign up to request clarification or add additional context in comments.

Comments

2

Looking at the API I don't see them passing the parameters like you are doing. Try some of their suggestions. Here is one.

$.get("updatecart.php", { itemnumber: itemid, todo: todo } );

1 Comment

In your updatecart.php how are you returning the data? Here's a small example that I wrote that works. Sorry, didn't mean to hit return. Give me a second and I'll post the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.