mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
2153c51d15
Add basic ajax post example for custom scheme handler test page/handler
62 lines
1.7 KiB
HTML
62 lines
1.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<title>Scheme Handler Test</title>
|
|
|
|
<script type="text/javascript">
|
|
var htmlNode;
|
|
var newLine = "\n";
|
|
var showError = function (text)
|
|
{
|
|
if (!htmlNode)
|
|
{
|
|
htmlNode = document.createElement("div");
|
|
htmlNode.id = "debugWindow";
|
|
document.body.appendChild(htmlNode);
|
|
}
|
|
|
|
htmlNode.innerHTML += "<p>" + text + "</p>";
|
|
};
|
|
|
|
var doRequest = function (data, contentType)
|
|
{
|
|
var x = new XMLHttpRequest();
|
|
x.open("POST", "custom://cefsharp/PostDataAjaxTest.html");
|
|
x.setRequestHeader("Accept", "application/json, text/javascript");
|
|
x.setRequestHeader("Content-Type", "application/json");
|
|
|
|
x.onreadystatechange = function (event)
|
|
{
|
|
if (x.readyState !== 4)
|
|
{
|
|
return;
|
|
}
|
|
|
|
showError(event.responseText);
|
|
};
|
|
|
|
x.onerror = function (e)
|
|
{
|
|
showError(e);
|
|
};
|
|
|
|
x.send(data);
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1>Success</h1>
|
|
<p>Scheme Handler Functioned Correctly</p>
|
|
|
|
<form action="custom://cefsharp/PostDataTest.html" method="post" target="_blank">
|
|
User:<input type="text" name="user" value="lion" />
|
|
<br>
|
|
Pass:<input type="text" name="pass" value="123" />
|
|
<br>
|
|
<input type="submit" value="Test POST Data" />
|
|
</form>
|
|
|
|
<h1>Custom Post using Ajax</h1>
|
|
<button onclick="doRequest('name=test&value=anotherValue'); return false;">Submit via ajax</button>
|
|
</body>
|
|
</html> |