Ajax调用DB保存仅在Wordpress中偶尔使用

I am creating a plugin and all functionality seems to work ok. However, in the admin page i am using an ajax call to a php file to save information entered into a form.

Sometimes it saves, other times it doesn't.

  1. THE FORM - call example

    form onsubmit="functionCall()" id="formSave"

  2. AJAX FUNCTION

     var url = 'http://localhost/';
    var link_id = '1';
    $.ajax({
                    url: url+"/wp-content/plugins/wpCountdown/admin/save.php?link_id="+link_id,
                    type: "post",
                    data: $("#formSave").serialize(),
                    success: function(d) {
    
                        alert('saved');
                    }
                });
    

In Chrome it more often than not saves fine.

Safari and chrome, the alert() is not called and only sometimes is the information saved.

Questions are: 1. am I calling ajax correctly (i have initiated this in the index file). 2. are there reasons it saves sometimes and not others and appears to work in other browsers.

Apologies, hope this is enough detail to be posting on here for the first time

You should read the WordPress Codex material on Ajax (http://codex.wordpress.org/AJAX_in_Plugins).

Ajax calls need to go through a special WordPress handler given by

admin_url('admin-ajax.php');

and you need a PHP handler function.