Illegal invocation error in ajax (Jquery 1.7.1)

后端 未结 2 1603
無奈伤痛
無奈伤痛 2021-01-17 03:15

I am trying to post an ajax request using jquery

var peName = document.getElementById(\"peName\").value;
     var peSubName = document.getElementById(\"peSub         


        
相关标签:
2条回答
  • 2021-01-17 03:48

    I'm a novice, but this error happened to me when I did something like the following:

    // the following will *error*
    var element = $("#elementId");
    $.post("/foo/bar/", { xxx : element });
    

    Anytime you feed $.post something other than a string, JS errors. i.e., peId, pecatId, etc. must all be strings, not jQuery objects.

    0 讨论(0)
  • 2021-01-17 03:54

    Ok, so you seem to be missing your function call closure bracket.

    $.post("/product/saveEditProduct",
        {  
            peId    :   peId,
            pecatId :   pecatId,
            peName  :   peName,
            peSubName  : peSubName,
            peDesc : peDesc,
            pePrice : pePrice,
            radioActive : radioActive,
            radioSpicy : radioSpicy,
            radioVeg : radioVeg,
         });
    
    0 讨论(0)
提交回复
热议问题