My POST send not all the information in a string and also change it, how
can i send it?
I have being stock a long time in a ajax problem, and after looking a lot
i decide to ask for help.
I'm trying to send a svg vector from a html (taking the tag ) using ajax
to a php for make a file of this vector, name.svg.
The problem is that at the moment when the ajax send the information using
POST, the information is changed and not pass all of it.
How you know the svg vectors have a lot of information that is why I use
POST.
This is my .js script:
function sendVector(url){
ajax=AjaxCaller();
ajax.open("POST", url, true);
ajax.onreadystatechange=function(){
if(ajax.readyState==4){
if(ajax.status==200){
//div.innerHTML = ajax.responseText;
}
}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
var vector2 = $("#grafico").html();
ajax.send('vector2='+vector2);
}
And this one is the php:
<?php
function escribirArchivo($vector21) {
$file = 'sion.svg';
$current = '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';
$current .=$vector21;
file_put_contents($file, $current);
}
echo escribirArchivo($_POST['vector2']);
?>
I don't know what i'm doing bad, because i dont have the result i want.
This is the file created.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"
width=\"1271\" height=\"400\"><desc>Created with Highcharts
3.0.4</desc><defs><clipPath id=\"highcharts-1\"><rect fill=\"none\"
x=\"0\" y=\"0\" width=\"1203\"
height=\"276\"></rect></clipPath><linearGradient x1=\"0\" y1=\"0\"
x2=\"0\" y2=\"1\" id=\"highcharts-4\"><stop offset=\"0\"
stop-color=\"#FFF\" stop-opacity=\"1\"></stop><stop offset=\"1\"
stop-color=\"#ACF\"
stop-opacity=\"1\"></stop></linearGradient></defs><rect rx=\"5\"
ry=\"5\" fill=\"#FFFFFF\" x=\"0\" y=\"0\" width=\"1271\"
height=\"400\"></rect><g class=\"highcharts-button\"
style=\"cursor:default;\" title=\"Chart context menu\"
stroke-linecap=\"round\" transform=\"translate(1237,10)\"><title>Chart
context
menu</title><rect rx=\"2\" ry=\"2\" fill=\"white\"
x=\"0.5\" y=\"0.5\" width=\"24\" height=\"22\"
stroke=\"none\" stroke-width=\"1\"></rect><path
fill=\"#E0E0E0\" d=\"M 6 6.5 L 20 6.5 M 6 11.5 L 20 11.5 M
6 16.5 L 20 16.5\" stroke=\"#666\" stroke-width=\"3\"
zindex=\"1\"></path>
That don't have even the 5% of information, furthermore is add a backslash
before every double quotes.
I had tested the string before send it to the php and I have all the
information that I need, but the problem is in between the send and the
php, and i don't know how make run it.
I hope you can help me :)
No comments:
Post a Comment