1

I am trying to send value of "MyProject" Onther function as bellow. (Simply I want to send value from SPservice to another Script) . How can I combined this?

<script language="javascript" type="text/javascript">

$(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "MyCustomList",
    CAMLViewFields: "<ViewFields></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var MyProject = $(this).attr("ows_Project");
		
		});
    }
  });
});
</script>

<script language="javascript" type="text/javascript">
$(document).ready(function () {		
            var appointments = new Array();
            var appointment1 = {
                
                description: "George brings projector for presentations.",
                location: "",
                subject: "Quarterly Project Review Meeting",
                Project: <I want MyProject to here>,
				
                
            }
	});
</script>

1
  • Combine it how? You will either need to call a function using that as a parameter, return that value to something, or set a variable to the value that can be used elsewhere. Commented Jun 2, 2016 at 13:21

2 Answers 2

1
<script language="javascript" type="text/javascript">
    $(document).ready(function() {
     $().SPServices({
        operation: "GetListItems",
        async: false,
        listName: "MyCustomList",
        CAMLViewFields: "<ViewFields></ViewFields>",
        completefunc: function (xData, Status) {
           $(xData.responseXML).SPFilterNode("z:row").each(function() {
                var MyProject = $(this).attr("ows_Project");
                myFunction(MyProject)
           });
        }
    });
   });

function myFunction(myProject){
        var appointments = new Array();
        var appointment1 = {

            description: "George brings projector for presentations.",
            location: "",
            subject: "Quarterly Project Review Meeting",
            Project: myProject,


        }
}
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

You can name the first function and at the end

return MyProject;

and then on the second function, you just call the previous function doing

Project: NameOfFirstFunction(),

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.