-1

I am trying to add an ajax function to a webpage and executed it using C#. Here it is my code:

HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = webBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
element.text = "function sayHello() { $.ajax({type: 'GET', url: '/gres/ajax/archive-odds.php',data:'&outcome='+'27498xv498x0x0'+'&provider='+'14',cache:!1,dataType:'xml', success: function (data) { alert('sucess'); }, complete: function () {} }); $('body').html(); }";
head.AppendChild(scriptEl);
object res = webBrowser1.Document.InvokeScript("sayHello");

My code, doesn't gave me any error. But the res object is always null. Can anybody help me??

Thanks

Hamid_UMB
  • 317
  • 4
  • 16

1 Answers1

1

Your js function doesn't return any values.

Try something like in this example

Community
  • 1
  • 1
Andrew Diamond
  • 6,295
  • 1
  • 15
  • 33