My Jquery function goes like this

<script language="javascript" src="jquery.js">
    function TestJQ() {
        alert("Inside a JQ Function");
    }
</script>

I also added jquery.js file to project.

When i try to call this function from Silverlight project it throws an error Failed to Invoke

My Silver light code:

void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            HtmlPage.RegisterScriptableObject("silverlightApplication", this);

        }

private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            HtmlPage.Window.Invoke("TestJQ");
        }

Important: When i remove the src value from script attribute, it works.

Can any one help on this?

Try this
<script type="text/javascript" src="jquery.js"></script>
<script language="javascript">
function TestJQ() {
alert("Inside a JQ Function");
}
</script>

First line will add javascript script to your project, and the second is additional javascript code that isn't connected with 'jquery.js' code.

Thanks, it did...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.