0

A bit of a newbie question but I am confused here.

I understand how post/get requests works.

I am trying to understand this code for test.aspx:

....
Response.Write("<script type='text/javascript'>");
Response.Write("function submitForm()");
Response.Write("{");
Response.Write("document.form4.submit();");
Response.Write("}");
Response.Write("submitForm();");
Response.Write("</script>");

Where form4 is a form thats action is a post call to some webservice(testWebservice).

So I am a bit confused, If i call test.aspx the response I should get is the response from the webservice testWebservice ?

Sorry if i am not clear enough let me know.

Jeroen
  • 1,162
  • 1
  • 11
  • 22
omriman12
  • 1,528
  • 6
  • 24
  • 45

1 Answers1

0

This writes a piece of javascript to the response stream, making it execute on the client when called. In this case it submits a form, resulting in calling a web service and returning its answer.

This is the same as you would return a JavaScriptResult, but is considered bad practice because you mix UI and controller logic (see Working example for JavaScriptResult in asp.net mvc).

In other words, try to avoid this.

Community
  • 1
  • 1
L-Four
  • 12,583
  • 8
  • 58
  • 104