Web Callback html code

If you want to insert a form into your site without using a frame, you need to insert

dataType: “jsonp”,

in your code
like that:

<div id="frame">
	<input type="text" name="num" placeholder="enter number here" id="webcallbackinput" value="">
	<input type="hidden" id="dest" value="https://site.com/wcb.php">
	<input type="hidden" id="i" value="1">
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#frame').click(function(e){
		if($(e.target).attr("id") == "webcallbackinput") {
			return;
		}
		//ensure we have a value before posting
		if ($('#webcallbackinput').val()) {
			var but = $(this);
			$.ajax({
				url: $('#dest').val(),
				type: 'post',
                            dataType: "jsonp",
				data: {p: $('#webcallbackinput').val(), i: $('#i').val()},
			 	cache: false,
				success: function(data, b, c) {
					data = $.parseJSON(data);
					console.log(data)
					switch (data.Response) {
						case 'Error':
							switch (data.Message) {
								case 'Originate failed':
									alert('');
									break;
								default:
									alert(data.Message);
									break;
							}
							break;
						case 'Success':
							alert('')
							break;
						default:
							break;
					}
				},
				error: function(a, b, c) {
					console.log(a, b, c);
					alert('');
				}
			})
		}
	})
});
</script>
1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.