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,168
  • 1
  • 12
  • 24
omriman12
  • 1,644
  • 7
  • 25
  • 48

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
  • 13,345
  • 9
  • 65
  • 109