Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ie7 Expected identifier, string or number with AJAX function

I ma using AJAX to update a database and it works well on all browsers except IE7. Before I give up and decide that users IE7 should be asked to upgrade I thought I'd check and make sure I'm not missing something obvious seeing as I'm very new to AJAX.

Script debugging throws an error saying 'SCRIPT1028: Expected identifier, string or number' identifying the offending character as the second to last curly brace

<script>
  function save_pos_reasons()
  {
    $.ajax({
    type: "POST",
    url: "save_pos_reasons.php",
    data: $('#add_positioning').serialize(),
    });
 }
</script>

And when I try to run the function it says

SCRIPT5007: The value of the property 'save_pos_reasons' is null or undefined, not a function object.

and identifies the line below as the cause.

<input type="button" class="submit" value="Save" onClick="save_pos_reasons()"/>

I am beginning to wonder if it is the JQuery serialize function that it is struggling with

like image 268
tatty27 Avatar asked Mar 14 '26 16:03

tatty27


1 Answers

You have to get rid of the trailing comma.

data: $('#add_positioning').serialize(), //this comma is the culprit
like image 54
Towler Avatar answered Mar 16 '26 06:03

Towler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!