I am getting problems attempting to call a Javascript function from an enqueued javascript file used although editing Wordpress pages. I've produced an easy meta box with a few AJAX hyperlinks that I wish to have the ability to call functions in the Javascript file (pretty simply stuff however i keep getting error "blah(1) isn't defined".


<a href="#" class="delete_pimg" id="pimg_1" onclick="blah(1);return false;">Delete Item</a>


function blah(theid){

if ( confirm("Are you sure you wish to remove this image (Note: Images are not removed from the Media Library)?") ) {

    var data = {
    action: 'myajax-delete',
    imgid: theid

    jQuery.post(ajaxurl, data, function(response) {

        //Parse the JSON Object
        var object = jQuery.parseJSON(response);

        if ( response.status == 'true' )
            jQuery('#file_' + theid + '_row').remove(); //remove TR
            alert('Image removed from this portfolio');
            alert('Sorry, that image could not removed right now, please reload the page and try again.');  


Note: The PHP server side code works fine and responds absolutely not surprisingly to my manual Posts. The javascript file is certainly present and being downloaded through the browser not surprisingly.

Basically make use of the following type of code below, the AJAX works (and so i be aware of JS is alright) but I have to have the ability to call the function by title rather make use of a selector. I am very keen to sort out why I can not call an easy function!!!!

jQuery('.delete_pimg').click(function() { ^Above code^ } 

Simply to re-cap the mistake I recieve once the link is clicked on: 'blah(1) isn't defined'

I really hope I have described this clearly - otherwise, please produce a shout :)

Ok Essentially - I possibly could not get this work. My javascript is completely fine, so To be able to call my very own functions, I declared them inside the page itself instead of bringing in a JS file. This appears to operate and my code performed without any errors immediately.


<script type="text/javascript">function blah(id){alert("This Works Nicely!");}</script>

A piece around but a minimum of solved my problem anyway.

Baby wipes sweat from temple