0

I have updated the ajax, but still passing nothing, I am getting crazy, please some one help me out here. It must be working :(

function ajaxFunction(gotid){
    alert (gotid)  

    $.ajax({
       type: "POST",
       url: "profile/php/getorder.php",
       data: {
         dataString: gotid
        },
       success: function(msg){
          alert( "Data Saved: " + msg );
       } 
     });
    }

and the PHP

 <?php 
   $ordid = $_POST["dataString"];
   $ordid = mysql_real_escape_string($ordid);
   echo $ordid; 

?>

why cant see the alert( "Data Saved: " + msg ); ? Help :(

1 Answer 1

0

if you are using jquery in your pages (like stated in the tags of the question) you'd better make use of it! No need to use XMLHttpRequest. Have a look at this jquery snippet and the jquery docs http://api.jquery.com/jQuery.ajax/

$.ajax({
    url: '/path/to/file',
    type: 'default GET (Other values: POST)',
    dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
    data: {param1: 'value1'},
})
.done(function() {
    console.log("success");
})
.fail(function() {
    console.log("error");
})
.always(function() {
    console.log("complete");
});
Sign up to request clarification or add additional context in comments.

6 Comments

hi, I have modified the function $.ajax({ type: "POST", url: "profile/php/getorder.php", data: { sndid: gotid} }) .done(function( msg ) { alert( "Data Saved: " + msg ); }); } but still no luck, and now I don't have the 2nd alert even
you should use GET because your php is listening for GET-parameters, not post.
yes I know that, I have changed the server side too, but no luck
open firebug console and see if you're getting the console messages. Also I see in your updated question (codeblock) a syntax error. there is a redundant } at the end. The code in my answer is working 100% sure.
please have look at the updated function, is there any thing wrong with the way that I am using the function ?
|

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.