2
$\begingroup$

When I execute this code locally on my laptop...

myForm = FormFunction[{"poop" -> "Number"}, 
   Module[{}, ode = x'[t] == #poop x[t];
     initialCondition = x[0] == 1;
     solution = NDSolve[{ode, initialCondition}, x[t], {t, 0, 1}];
     Plot[x[t] /. solution, {t, 0, 1}]] &];

myForm[]

... a form is returned that prompts me to enter a numerical value for a parameter called "poop". If I enter the number 2 into this form and click "Submit", this plot is returned:

enter image description here

When I execute this code instead...

CloudDeploy[FormFunction[{"poop" -> "Number"},
   Module[{}, ode = x'[t] == #poop x[t];
    initialCondition = x[0] == 1;
    solution = NDSolve[{ode, initialCondition}, x[t], {t, 0, 1}];
    Plot[x[t] /. solution, {t, 0, 1}]] &]]

... a link is returned to a web page on which a similar form appears. If I enter the number 2 into this form and click "Submit", a page is returned that displays this Graphics command instead of a plot:

enter image description here

If I paste this Graphics command into Mathematica locally, the plot above is returned.

I'd like to know how I should alter my second block of code so that the plot appears in my browser in response to my submitting a number through the web-based form.

I can get the plot to appear in my browser by executing a command like this...

CloudDeploy[Module[{},
  myForm = 
   FormFunction[{"poop" -> "Number"}, 
    Module[{}, ode = x'[t] == #poop x[t];
      initialCondition = x[0] == 1;
      solution = NDSolve[{ode, initialCondition}, x[t], {t, 0, 1}];
      Plot[x[t] /. solution, {t, 0, 1}]] &];
  myForm[]]]

... but in this case the form prompting me to enter the number "poop" appears locally on my machine and a web link is returned only after I've submitted a value.

$\endgroup$
  • $\begingroup$ I can't reproduce the problem. Is this still the case? If so, adding appriopriate ExportForm for FormFunction's result should handle such cases. Since I can't reproduce it and you were not around for a long time I will close it, but let me know if you disagree or want to update it. $\endgroup$ – Kuba May 28 '18 at 10:11
  • $\begingroup$ I'm voting to close this question as off-topic because the problem can't be reproduced. $\endgroup$ – Kuba May 28 '18 at 10:12