pbojinov
1/22/2014 - 7:43 AM

BigML cross-domain post

BigML cross-domain post

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>BigML Prediction Test</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="http://code.jquery.com/jquery-1.7.1.js" type="text/javascript"></script>
</head>

<body>
    <h1>Post Prediction</h1>
    <div id="prediction">Predicting...</div>
    <script type="text/javascript">
    jQuery(document).ready(function() {
        var data = {
            model: "model/52b35e54035d0745d8000000",
            input_data: {
                "000000": 90
            }
        };

        jQuery.ajax({
            url: "https://bigml.io/prediction?username=francisco;api_key=aefaccb7210c1300f9ef2fb85e3296e27ceac210",
            type: "POST",
            crossDomain: true,
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify(data),
            success: function(prediction) {
            	console.log(prediction);
            	$('#prediction').html(JSON.stringify(prediction));
            },
            error: function(error) {
            	console.log(error);
            	$('#prediction').html(error.statusText);
            }
        });
    });
    </script>
</body>
</html>