I have got this html:
<div id="myDiv">
<p class="readMore"></p>
<p class="readMore"></p>
<p class="readMore"></p>
</div>
I have got this jquery function:
UPDATE
<script>
function getData()
{
$.ajax({
url: "http://localhost/test2/ajax.php",
type: "GET",
datatype: "json",
success: function(data)
{
alert("This is my data: "+data);
},
error: function( error )
{
alert(JSON.stringify(error));
}
});
}
</script>
Result status 0 . on the alert
Thats the output from ajax.php page:
[{"Article1":"11111111111111111"},{"Article2":"22222222222222222222"},{"Article3":"333333333333"}]
I need to take the rows and encode them to a jason..the problem is who do I do that?
And how do I insert the data into the 3 paragraphs on the success of the ajax call.?
To make up JSON use: http://lv.php.net/manual/en/function.json-encode.php
To put data into paragraphs… one way to go is to assign ID to each paragraph and then traverse response from server and put data in each appropriate paragraphs. There are other ways to do this, but lets try this – you make something and then I (or we) will help to fix problem if you will run into any.
In success use something like this: