javascript - newbie ajax and php get parameters -


i need small don't know how solve it. have javascript file ajax inside this

$.ajax({     data: "mc_id="+someid,     url: "includes/getdataprs.php",     type: "get",     datatype: "json",     async: false,     success: function(msg){           //some function here     } }); 

in getdataprs.php

<?php include_once 'db_connect.php'; include_once 'functions.php';    sec_session_start();   header('content-type: application/json');    $id = null;   $date = null;   $limit = 0;   if (isset($_get['mc_id'])) {     $id = $_get['mc_id'];   }   //some process here $data   echo json_encode($data); 

i can data $_get['mc_id'] when need more data , change parameters in javascript this

$.ajax({     data: "{'mc_id':'"+someid+"','limit':'"+somelimit+"'}",     url: "includes/getdataprs.php", 

and got nothing in php $_get['mc_id'] or $_get['limit'] in desperate solve it, put in url "includes/getdataprs.php?mc_id=someid&limit=somelimit

any comment or suggestion appreciated in advance

passing multiple variable in ajax should like

$.ajax({     data: {mc_id: someid, limit: some_limit},     url: "includes/getdataprs.php",     type: "get",     datatype: "json",     async: false,     success: function(msg){       //some function here     } }); 

it better use data: {mc_id: someid, limit: some_limit} because treated object itself.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -