How to stop the "OK" Response on New Web Page after a HTTP Post/InputPort

Is it possible to stop the Electric Imp API Server from sending the OK response to a POST, which is causing my web browser to open a new page each time I submit a form with the POST requests to my Imp? I’m using a simple HTML Form w/Buttons to change the state of the GPIO Pins using InputPort.

If not, does anyone know HTML code that would handle this better than having a new page open reading “OK” after each time I press a Submit button?

My IMP Code:

// PinOutputCtrl_125789 Controller code

// Configure pins 1, 2,5,7,8,9 as Outputs w/pullup
hardware.pin1.configure(DIGITAL_OUT_OD_PULLUP);
hardware.pin2.configure(DIGITAL_OUT_OD_PULLUP);
hardware.pin5.configure(DIGITAL_OUT_OD_PULLUP);
hardware.pin7.configure(DIGITAL_OUT_OD_PULLUP);
hardware.pin8.configure(DIGITAL_OUT_OD_PULLUP);
hardware.pin9.configure(DIGITAL_OUT_OD_PULLUP);

// Set pins 1, 2,5,7,8,9 as OFF at start
hardware.pin1.write(0);
hardware.pin2.write(0);
hardware.pin5.write(0);
hardware.pin7.write(0);
hardware.pin8.write(0);
hardware.pin9.write(0);

// Input port to accept web pin output values
class PinOutRequest extends InputPort
{
name = “Status”;
type = “string”;

function set (request)
{
    server.show("Status Requested:  " + request);
    if (request == "Pin 1: On") {hardware.pin1.write(1);}
    if (request == "Pin 1: Off") {hardware.pin1.write(0);}     
    if (request == "Pin 2: On") {hardware.pin2.write(1);}
    if (request == "Pin 2: Off") {hardware.pin2.write(0);}
    if (request == "Pin 5: On") {hardware.pin5.write(1);}
    if (request == "Pin 5: Off") {hardware.pin5.write(0);}       
    if (request == "Pin 7: On") {hardware.pin7.write(1);}
    if (request == "Pin 7: Off") {hardware.pin7.write(0);}
    if (request == "Pin 8: On") {hardware.pin8.write(1);}
    if (request == "Pin 8: Off") {hardware.pin8.write(0);}
    if (request == "Pin 9: On") {hardware.pin9.write(1);}
    if (request == "Pin 9: Off") {hardware.pin9.write(0);}          
}

};

// Register with the server
imp.configure(“PinOutputCtrl_125789”, [ PinOutRequest() ], []);

// End of code.

Output Pin Control (1,2,5,7,8,9)







I created an ASP.NET page which executes on a server. This is a Microsoft only solution - there should be similar functions available for all the other platforms out there. You can download Web Matrix from Microsoft for free which gives you IIS Express and the ASP.NET platform which you can host on your development computer. Then on the server side you can programatically post the data to the imp server. once development is complete, you will need to host your ASP.NET solution on an external server.

`
HttpWebRequest impHttpWebRequest = null;
HttpWebResponse impHttpWebResponse = null;

//Create Request
impHttpWebRequest = (HttpWebRequest) HttpWebRequest.Create(“https://api.electricimp.com/v1/your imp specfic url here/?value=ImpTestValue”);

impHttpWebRequest.Method = “POST”;
impHttpWebRequest.ContentType = “text/xml; encoding=‘utf-8’”;

//Get Response - this is where the call to the imp server is made. Don’t care about the response right now - imp server returns OK
//In future decode the stream to make sure response is correct
impHttpWebResponse = (HttpWebResponse) impHttpWebRequest.GetResponse();

`

Hope that helps.