AJAX returned data - how to treat them with jQuery -


so when jquery makes $.ajax request, returned data can handled success function attribute (a function) of object passed parameters $.ajax. api docs report, if processdata attribute set true, data returned string, otherwise dom object (is right?).

so, need treat data if simple html. let's have prepend , append series of =s every h1 tag in returned data, , fill page data if plain string (in order use jquery .html() method).

what's correct way it?

i found .parsehtml() jquery function useful in order parse returned data string html dom. how treat it?

sorry lack of what have tried in question.

edit

someone suggested more clear example. have .html file content want retrieve through ajax , use fill main page content. file structured simple html, without head/body tags, ps , few h1s. through css made h1 tags ps (which intended). want transform this:

<h1>i'm simple header</h1> 

into plain text this:

=================== i'm simple header =================== 

kind of unix terminal style.

edit below working me

file1.html

<script type="text/javascript"> $(document).ready(function(){ $.ajax({       url: 'http://voicing-up.com/test.html',           success: function(data) {                   alert(data);             alert($(data).html());         }       }); }); </script> 

test.html

<p>this data</p> <h2>this h2</h2 

in code above, data going return dom elements, , there can use jquery's .html() function innerhtml of element.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -