I have a form that lets a user perform a search for a stock symbol. The data is transmitted to another URL via PHP cURL. This is fine, we do this several other places on the site. I need to be able to trim the returned data (it returns a whole page) and only display the data between the
{STARTKINETICK}
{ENDKINETICK}
parts.
I need to have it displayed in a div#results. Please help! this should be so simple!
$(document).click(function() {
$("#SymbolSearchForm").submit(function() {
$.ajax({
url: "PHP/Kinetick_Symbol_Search.php",
type: "post",
dataType: "HTML",
success: function(html){
html = $.trim(html);
html = html.match(/\{STARTKINETICK\}(.*)\{ENDKINETICK\}/)[1];
var end = "{ENDKINETICK}";
$("#return").append(html.substring(html.indexOf("{STARTKINETICK}"), html.indexOf(end) + end.length));
}
});
});
});
You can use
html.indexOf("{STARTKINETICK}")andhtml.indexOf("{ENDKINETICK}")to get the starting and ending points and then usehtml.substring. Don’t forget to add the length of “{STARTKINETICK}” to the start point.EDIT