0

I am working on SharePoint 2013, there I created a Picture Lib. and I Created an Image carousel using J-Query but I want That When I click on Image it Redirect me to link Page who's URL I mention in Description Section of Image.

But When I implement it and output the value in that field, I get an

'Undefined`

Code which I am using to call Sp-services is as below

<html>

    <script>

    $(document).ready(function () {
                $().SPServices({
                    operation: "GetListItems",
                    async: false,
                    listName: "Pictures",
                    CAMLRowLimit: 6,
                    completefunc: function (xData, Status) {
                        var hasRows = false;
                        $(xData.responseXML).find("z\\:row, row").each(function () {
                            hasRows = true;
                            var _url = '/' + $(this).attr("ows_RequiredField")

                            var _title = $(this).attr("ows_Title");
                var _description = $(this).attr("ows_Description");

                            _slideDiv = $("<div class='slides_container_div'/>");
                            _link = $("<a  src='" + _url + "'/>");
                            _Image = $("<img  id='slideShowImage' src='" + _url + "'/>");
                            $(_link).append(_Image);
                            _slideDiv.append(_link);

                            _Title = $("<div class='caption'><p>" + _title + "</p></div>");
                            _slideDiv.append(_Title);

                _Description = $("<p>" + _description + "</p>");
                            _slideDiv.append(_Description);

                            $(".slides_container").append(_slideDiv);
                        });
                    }
                });
            });
    </script>
</html>
1
  • where is click event function?is this sample code?bcoz ur calling this function in document. ready. Commented Feb 29, 2016 at 9:24

2 Answers 2

1

Try to change the below line,

  completefunc: function(xData, Status) {
            $(xData.responseXML).SPFilterNode("z:row").each(function()

instead of this,

    completefunc: function (xData, Status) {
                    var hasRows = false;
                    $(xData.responseXML).find("z\\:row, row").each(function   () {
1

For starters, a-tags does not use the src attribute as you have used, but the href attribute. So replace

$("<a  src='" + _url + "'/>");

with

$("<a  href='" + _url + "'/>");

(By the way, a-tags is not self closing so I'm not sure what you are trying to accomplish?)

You also seem to use the same _url variable as both the source of the image tag and to the link, so please make sure you use the correct variables

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.