I am making submitting an ajax form with response coming back in Json. Everything works fine except for an instance where I needed to send response to you user containing some html, precisely a url link for the user to view specific data. So, the challenge is the callback response from the server fails thereby returning error. But if i remove the html link, everything works fine. Also, if i check the network information from the browser inspect element, the desired response message containing the link as expected is received but jquery seems to fail displaying it.
if it is important or necessary to state, it is a codeigniter based App.
Below is the html enclosed in the callback response :
<a href="www.myurl.com/index.php/student/parent-profile/b38d128b180b04afc">Click here to View Profile</a>
I need help on how to pass the url above alongside any other text coming back from the server. I need to know how to either by encoding and decoding the data from or any other alternate method of getting this done.
Below are some line from my js
jQuery.ajax({
url: site_url+'/add-student-process',
type: 'POST',
data: form_data,
dataType: 'json',
contentType: "application/x-www-form-urlencoded;charset=utf-8",
cache: false
})
.done(function(resp){
if(resp.type === "error"){
jQuery("#ajax_form_resp").html(resp.value);
}
else if(resp.type === "okay"){
jQuery("#ajax_form_resp").html(resp.value);
}
})
.fail(function(){
jQuery("#ajax_form_resp").html('Error encountered while processing request. Pls try again shortly.');
});
Would be really glad getting help with this.