I have a JSP-servlets application which is deployed on tomcat.Now from my html I need to make web(Ajax) call and call the CQ5 webpage(which is entirely running in CQ instance). When i click on submit button, it goes in the error method of ajax call. Here is the code
<linkhref="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"rel="stylesheet"type="text/css">
<scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"type="text/javascript"></script>
<scriptsrc="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"type="text/javascript"></script>
<scripttype="text/javascript"src="http://crypto-js.googlecode.com/svn/tags/2.5.4/build/crypto/crypto-min.js"></script>
<scriptsrc="/resources/scripts/mysamplecode.js"type="text/javascript"></script>
<scripttype="text/javascript">
$(document).ready(function(){
$("#myAjaxRequestForm").submit(function(e){
e.preventDefault();
});
$("#myButton").click(function(e){
//get the form data and then serialize that
dataString = $("#myAjaxRequestForm").serialize();
$.ajax({
type:'GET',
url:'http://localhost:4502/content/geometrixx/en/products/triangle/jcr:content/par/text_0.infinity.json',
dataType :'json',
'beforeSend':function(xhr){
var bytes =Crypto.charenc.Binary.stringToBytes('admin'+":"+'admin');
var base64 =Crypto.util.bytesToBase64(bytes);
xhr.setRequestHeader("Authorization","Basic "+ base64);//May need to use "Authorization" instead
},
error :function(){
alert('errro');
},
sucess:function(result){
alert('done');
}
});
});
});
</script>
<divid="allContent">
<divid="myExample">
<formid="myAjaxRequestForm">
<h1> Please enter the Order Information -</h1>
<labelfor="orderId">Order Id:</label>
<inputid="orderId"name="orderId"type="text"><br/>
<br/>
<labelfor="zipCode">ZIP Code:</label>
<inputid="zipCode"name="zipCode"type="text"><br/>
<br/>
<inputid="myButton"type="button"value="Submit">
</form>
</div>
<divid="ajaxResponse">
</div>
</div>
</head></html>