Here is the passage to which you are referring:
John 4:23 But the hour cometh, and now is, when the true worshippers shall worship the Father in spirit and in truth: for the Father seeketh such to worship him. 24 God is a Spirit: and they that worship him must worship him in spirit and in truth.
Here is another similar passage:
Philippians 3:3 For we are the circumcision, which worship God in the spirit, and rejoice in Christ Jesus, and have no confidence in the flesh.
We must first consider the context of John 4:24. John 4:19-24 makes up one unified piece. In order to take Jesus off track in His witnessing approach, the Samaritan woman brought up the argument between the Jews and the Samaritans as to where God should be worshipped. Should He be worshipped in Samaria as the Samaritans say or in Jerusalem as the Jews claim? Although Jesus maintained the authority of the Jewish teachings ("salvation is of the Jews"), He pointed to the time when the Father will not be worshipped in a particular location ("neither in this mountain, nor yet at Jerusalem'). The reason for this development has to do with the essential nature of God. He is a Spirit and therefore His worship is not limited to a physical location. True worship of Him is not physical worship in a physical location; it is spiritual worship. The point of the argument contrasts the physical with the spiritual and declares that God is spiritual; not physical.
Historically, physical worship meant that worship was limited to going to one particular place and physically acting in certain ways (as in taking offerings to the Temple in Jerusalem). However, true worship is spiritual; not physical. It is the worship of the inner man and is not found in the outward actions of the flesh. Even when physical actions are connected to worship (as the singing of praise to God and the offering of financial gifts), the true worship is not to be found in the outward actions but in the condition of the heart. Songs can be sung and money can be given in an outward manner without the full participation of the spiritual man. These actions are then not true worship. True worship is that which comes from the inner man and the Father seeks such to worship Him (John 4:23).
The word worship comes from worth+ship. It means to declare the worthiness of (Revelation 5:9-12 - "Worthy is the Lamb that was slain to receive power, and riches, and wisdom, and strength, and honour, and glory, and blessing"). Therefore, worship is not limited to a place or the performance of a ceremony. Rather, it is an inward attitude of reverence and exaltation expressed by an outward act of praise (Psalm 29:2 - "Give unto the LORD the glory due unto his name; worship the LORD in the beauty of holiness"). According to the passage in John 4:22-24, true worship has three characteristics. First it is sane (John 4:22) - "we know what we worship" (1 Corinthians 14:14-15, 26-33; Colossians 3:16). Second, it is spiritual (John 4:24) - "in spirit." Third, it is sincere (John 4:24) - "in truth."
Notice that we are to worship God in spirit and in truth (John 4:24). The phrase "in truth" is used in important ways in scripture. It means that our heart must match our deeds (1 John 3:18 - "My little children, let us not love in word, neither in tongue; but in deed and in truth.") It means to act without hypocrisy. Philippians 1:18 contrast two opposites: "whether in pretence, or in truth." That which is done in truth is not pretended or faked. Therefore, to act in truth is to act without falsehood and without fear of what others think. The Jews said of Jesus: "for thou regardest not the person of men, but teachest the way of God in truth" (Mark 12:14). To worship God in spirit and in truth is the highest form of worship and the only kind of worship God ultimately desires.
The question may arise as to what the spirit is. According to Romans 8:16, "The Spirit itself beareth witness with our spirit, that we are the children of God." The spirit of man is that part of him that communicates with God's Spirit and that on a moment by moment basis receives its life from God's Spirit. The Holy Spirit works in our heart through our spirit. "But the natural man receiveth not the things of the Spirit of God: for they are foolishness unto him: neither can he know them, because they are spiritually discerned" (1 Corinthians 2:14). The natural man is the lost man, being what he is by nature alone. The spiritual man (the one who has his spirit quickened in salvation and is in submission to God) receives the things of the Spirit of God and responds to that Spirit.
As such, we can do as did Paul when he said, "For God is my witness, whom I serve with my spirit in the gospel of his Son" (Romans 1:9). We can pray, both in the spirit and in the Spirit (1 Corinthians 14:15; Ephesians 6:18; Jude 1:20). And, we can worship God in spirit and in the spirit; that is, in the inner spiritual man. May we all learn to worship our Lord in such a manner.