Last active
December 19, 2015 06:09
-
-
Save pierrelorioux/5909208 to your computer and use it in GitHub Desktop.
iframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
</head> | |
<body> | |
<form action="/" id="searchForm"> | |
<input type="text" name="s" placeholder="Search..." /> | |
<input type="submit" value="Search" /> | |
</form> | |
<!-- the result of the search will be rendered inside this div --> | |
<div id="result"></div> | |
<script> | |
/* attach a submit handler to the form */ | |
$("#searchForm").submit(function(event) { | |
/* stop form from submitting normally */ | |
event.preventDefault(); | |
/* get some values from elements on the page: */ | |
var $form = $( this ), | |
term = $form.find( 'input[name="s"]' ).val(), | |
url = $form.attr( 'action' ); | |
/* Send the data using post */ | |
var posting = $.post( url, { s: term } ); | |
/* Put the results in a div */ | |
posting.done(function( data ) { | |
var content = $( data ).find( '#content' ); | |
$( "#result" ).empty().append( content ); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.get("test.php", | |
function(data) { | |
$('body').append( "Name: " + data.name ) // John | |
.append( "Time: " + data.time ); // 2pm | |
}, "json"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
<script type="text/javascript"> | |
function submitFormToIFrame(){ | |
//IE | |
if( document.myform ){ | |
document.myform.setAttribute('target','frame_x'); | |
document.myform.submit(); | |
//FF | |
} else { | |
$.post("test.php", { name: "John", time: "2pm" } ); | |
var form=document.getElementById('myform'); | |
form.setAttribute('target', 'frame_x'); | |
form.submit(); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<h1>Hello Erwin!</h1> | |
<form id="myform" name="myform" action="result.html" target=""> | |
<input type="button" value="Submit the Form" onClick="submitFormToIFrame();"> | |
</form> | |
<span id="iframeSlot"> | |
<iframe name="frame_x"> | |
</iframe> | |
</span> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: "POST", | |
url: url, | |
data: data, | |
success: success, | |
dataType: dataType | |
}); | |
$.post("test.php", { name: "John", time: "2pm" } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
</head> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment