jQWidgets Forums

jQuery UI Widgets Forums Chart How could I POST a variable with ajax?

This topic contains 2 replies, has 2 voices, and was last updated by  Schmakus 10 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • How could I POST a variable with ajax? #67706

    Schmakus
    Participant

    Hi,
    I want so send an ajax request to my php-script. For examble “Cat_ID = 1”, to use this variable as “WHERE”-string for my MySQL-Select.
    Here is my Code:

    function displayDUTproInsert() {
    	function getExportServer() {
    		return 'http://www.jqwidgets.com/export_server/export.php';
    	}
        var source =
    	{
    		 datatype: "json",
    		 datafields: [
    			 { name: 'Anzahl', },
    			 { name: 'Ort'}
    			 
    		],
    		url: 'script/charts.php?select=2'
    	};
    	var dataAdapter = new $.jqx.dataAdapter(source, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + source.url + '" : ' + error); } });
    	// prepare jqxChart settings
    	var settings = {
    		title: "Prüflinge in den jeweiligen Eingangsregalen",
    		description: "",
    		enableAnimations: true,
    		showLegend: true,
    		showBorderLine: false,
    		legendLayout: { left: 480, top: 160, width: 300, height: 200, flow: 'vertical' },
    		padding: { left: 5, top: 5, right: 5, bottom: 5 },
    		titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },
    		source: dataAdapter,
    		colorScheme: 'scheme03',
    		seriesGroups:
    			[
    				{
    					type: 'pie',
    					showLabels: true,
    					series:
    						[
    							{ 
    								offsetX : 230,
    								dataField: 'Anzahl',
    								displayText: 'Ort',
    								labelRadius: 170,
    								initialAngle: 15,
    								radius: 145,
    								centerOffset: 0,
    								formatFunction: function (value) {
    									if (isNaN(value))
    										return value;
    									return parseFloat(value) + ' Prüflinge';
    								},
    							}
    						]
    				}
    			]
    	};
    	$('#DUTproInsert').jqxChart(settings);
    	$("#jpegButton1").jqxButton({});
    	$("#pngButton1").jqxButton({});
    	$("#jpegButton1").click(function () {
    		// call the export server to create a JPEG image
    		$('#DUTproInsert').jqxChart('saveAsJPEG', 'DUTproOrt.jpeg', getExportServer());
    	});
    	$("#pngButton1").click(function () {
    		// call the export server to create a PNG image
    		$('#DUTproInsert').jqxChart('saveAsPNG', 'DUTproOrt.png', getExportServer());
    	});
    	// auto update timer
    	var ttimer = setInterval(function () {
    		$('#DUTproInsert').jqxChart('update');
    	}, 3000);
    };
    	
    	// Display Charts
    	displayDUTproInsert();

    Thank you for your help. I’m a newbie. 😉

    How could I POST a variable with ajax? #67712

    Dimitar
    Participant

    Hello Schmakus,

    You can do this by setting the source data:

    var source = {
        datatype: "json",
        datafields: [{
                name: 'Anzahl',
            }, {
                name: 'Ort'
            }
    
        ],
        data: {
            Cat_ID: 1
        },
        url: 'script/charts.php?select=2'
    };

    We also have multiple PHP integration examples and help topics that you may find useful.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    How could I POST a variable with ajax? #67730

    Schmakus
    Participant

    Great, so easy…. 🙂 Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.