2

hello i am creating chat widget which provide chat widget website. i have created it but i dont know in some website it is working but in some website it is not working at all. right now i am facing this issue Undefined index: data_type in C:\wamp\www\college\chat_service_provider\receive_msg.php on line 69pt?. here is my code

$.ajax({
        url: "http://127.0.0.1/college/chat_service_provider/receive_msg.php",
        method: "POST",
        data: {
            data_type: 'userdata', //i have tried 'data_type'
            email: a,
            key: c
        },
        success: function(a) {
            b = a;
            alert(a);
        }
    })

andthe php code

echo $_POST["data_type"];

so in some website it is working properly and alert me userdata. but in some website it returning me Undefined index: data_type in C:\wamp\www\college\chat_service_provider\receive_msg.php on line 69 so please help me to find this issue thank you. now got the answer. i have changed code.

$.post("http://127.0.0.1/college/chat_service_provider/receive_msg.php",
    {
        data_type: 'userdata',
        email: a,
        key: c
    },
   function(a) {
        b = a;
        alert(a);
    })
1
  • so now because of jquery issue. some time it is sending data using GET method. i search alot but cant working it with 'type' OR 'method' . so i changed the code like this $.post("http://127.0.0.1/college/chat_service_provider/receive_msg.php", { data_type: 'userdata', email: a, key: c }, function(a) { b = a; alert(a); }) Commented Oct 16, 2016 at 18:58

2 Answers 2

1

Try using post instead:

var data = {"email" : email, "key":key}
$.post("demo_test.asp", function(data, status){
    alert("Email: " + data.key + " Key: " + data.key + "\nStatus: " + status);
});
Sign up to request clarification or add additional context in comments.

2 Comments

this one is from w3shools. and i think $.post is smaller version or $.ajax. ajax provide more functionality than $.post. so i dont think this gonna work. i wrote above script is working fine in some website but in some website it is showing me undefined index.
so finally it is working i use this method thank you.
0

Please use firebug and open up the console, when you do the Post request did "userdata" get sent over in the Post request?

Please troubleshoot from there.

8 Comments

as you see in above code i directly assign string 'userdata' to variable data_type so i think it will send that data. but still i want to check it. i am not well known of firebug. so i find it difficult. so can you please guide me how can i do that. i have firebug.
Open up Firefox then go to the webpage you are sending data. Then right click on the page and open firebug. It will open up a separate window at the bottom. Click on the "console" tab. When you do a post action (button etc) it will show the post request.
hey i do it and yes it is sending. but on above i am getting this link
127.0.0.1/college/chat_service_provider/… it is for get requet right? but i have used post so why it is sending as get ?
If it's a post then it will be a post, not a get. I highly recommend you double check the codes for the actions to execute the code. Maybe loading a wrong file, of a wrong button ID etc. can't figure out with these codes on your question. They looks logically correct.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.