Skip to content

Instantly share code, notes, and snippets.

@jdsharp
Created October 7, 2010 21:56
Show Gist options
  • Save jdsharp/615972 to your computer and use it in GitHub Desktop.
Save jdsharp/615972 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>jQuery Mockjax Example Query string</title>
<script src="../lib/jquery-1.4.2.js"></script>
<script src="../jquery.mockjax.js"></script>
<script>
$.mockjax({
url: '/rest',
data: { action: "foo" },
responseText: { bar: "hello world" }
});
$.mockjax({
url: '/rest',
data: { action: "bar" },
responseText: { bar: "hello world 2" }
});
$.ajax({
url: '/rest',
dataType: 'json',
data: {
action: "foo"
},
success: function(json) {
$('body').append('Response 1: ' + ( json.bar || 'ERROR' ) + '<br>' );
}
});
$.ajax({
url: '/rest',
dataType: 'json',
data: {
action: "bar"
},
success: function(json) {
$('body').append('Response 2: ' + ( json.bar || 'ERROR' ) + '<br>' );
}
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment