Home Ask Login Register

Developers Planet

Your answer is one click away!

user3902519 February 2016

Write non form data to xml using php

I am coding a video platform. When anyone sees the video and hit the like button the like should be incremented by one and should be written to xml file - I want to do this with php. And when the like symbol is clicked, the php should not be loaded but it should be executed.

Here is my code:


<a href='#' onclick='doLike(id)'><i class='material-icons'        style='float:bottom'>thumb_up</i></a>


function doLike(id){
    type: "POST",
    async: true,
    url: "likup.php",
    cache: false,
    contentType: false,
    processData: false,
    error: function(){alert('Cannot reach file');},
                alert("Saved Successfully");


$file = 'xml/shortfilm/filmname.xml';
$xml = simplexml_load_file($file);
$xml->Shortfilm[0]->like= 2;

But I am still unable to achieve what I want.


Lajos Arpad February 2016


On click doList(id) will be called. What is id? Is it defined? You need to make sure that this parameter has the correct value. Your doLike does not send the id to the server. You need to send it, otherwise your server will not receive it. Your server, in turn should process the request and save the like into the xml.

Post Status

Asked in February 2016
Viewed 1,748 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life