Okay so i got an idea which is not the cleanest but is going to work i guess.
So this is your code :
$('#Fetch').on( 'click', function( e ) {
e.preventDefault();
var MyUrl = 'http://******/faq.php?code=' + $('input[name=code]').val() + "&num=" + $('input[name=number]').val();
$.ajax( {
url: MyUrl,
type: "get",
dataType: 'html',
success: function( data ) {
$('#MyArea').val(data);
}
});
});
We can change the success and to the following: Create a <div></div>
container with display:none
style, then populate this div and after that get the #content from it. So it would look something like this:
$('#Fetch').on( 'click', function( e ) {
e.preventDefault();
var MyUrl = 'http://******/faq.php?code=' + $('input[name=code]').val() + "&num=" + $('input[name=number]').val();
$.ajax( {
url: MyUrl,
type: "get",
dataType: 'html',
success: function (data) {
$("body").append("<div id='contentContainer'></div>").css("display","none");
$("#contentContainer").html(data);
var content = $("#contentContainer #content").html();
$("#MyArea").val(content);
}
});
After that you can delete the div but you got the point.
EDIT:
Okay here's the better idea: You need to actually parse that info to jQuery variable and from there you can parse html like from DOM.
$('#Fetch').on( 'click', function( e ) {
e.preventDefault();
var MyUrl = 'http://******/faq.php?code=' + $('input[name=code]').val() + "&num=" + $('input[name=number]').val();
$.ajax( {
url: MyUrl,
type: "get",
dataType: 'html',
success: function (data) {
var container = $(data);
var content = $(container).find("#content").html();
$("#MyArea").val(content);
}
});
I think this is not gonna get any cleaner. Also it will work fast as we interact with DOM only once.