Building a button to command a SPS script

Jan 10, 2013 at 2:42 PM

Hi, have a small script with jquery and SPServices and it works very well inside a html-Webpart. the problem is that it always starts automatically and I would like to start it over some link or button. Like normal button inside the Wiki Page , inside HTML. I have tried a few options but none of them works.

 <script type="text/javascript" src="...../jquery-1.8.3.min.js">
        <script type="text/javascript">
        $(function () {
            var query = "<Query></Query>";
                operation: "GetListItems",
                listName: "Teilnehmerinen",
                async: false,
                CAMLQuery: query,
                completefunc: function (xData, status) {
                    if($(xData.responseXML).find("z\\:row").length <= '1')
                        $(window.location).href('href', '');
                    else {
                        $(window.location).href('href', ''); 

Jan 11, 2013 at 8:32 PM

I would try instead of wrapping the jQuery in $(function() { [your function] }); 

Try function giviitaname() { [your function] }

And in the button:

onclick ="giviitaname()"

Jan 17, 2013 at 7:38 AM
Edited Jan 17, 2013 at 7:38 AM

Thanks, worked straight away. I also removed  the $ sign and changed the redirect command to normal javascript like: