Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp with an AJAX request
    primarykey
    data
    text
    <p><strong><em>The Problem</em></strong><br> I am tring to do an ajax request to a PHP script, however I am having a problem getting the data into the format that the PHP is expecting it, the PHP is expecting the data to come in as array within an array something like, </p> <pre><code>Array ( [cv_file] =&gt; Array ( [849649717] =&gt; Y [849649810] =&gt; Y ) [save] =&gt; Save CVs ) </code></pre> <p><strong>What have I tried?</strong></p> <p>I have tried in my javascript to create an empty array and use that as the array key, something like this, </p> <pre><code> var cv_file = new Array(); $(".drag_check").draggable({helper:"clone", opacity:"0.5"}); $(".searchPage").droppable({ accept:".drag_check", hoverClass: "dropHover", drop: function(ev, ui) { var droppedItem = ui.draggable.children(); cv_file = ui.draggable.children().attr('name'); var link = ui.draggable.children().attr('name').substr(ui.draggable.children().attr('name').indexOf("[")+1, ui.draggable.children().attr('name').lastIndexOf("]")-8) $.ajax({ type:"POST", url:"/search", data:cv_file+"&amp;save=Save CVs", success:function(){ alert(cv_file) $('.shortList').append('&lt;li&gt;&lt;input type="checkbox" value="Y" class="checkbox" name="remove_cv['+link+']"/&gt;&lt;a href="/cv/'+link+'"&gt;'+link+'&lt;/a&gt;&lt;/li&gt;'); }, error:function() { alert("Somthing has gone wrong"); } }); } }); </code></pre> <p><strong>My Question</strong> </p> <p>How can I get the data into the format that the PHP is expecting, I would appreciate any help that anyone can give?</p> <p><strong>Edit</strong><br> On alerting what the poster in the comments suggested I get he following,</p> <p><code>cv_file[849649717]&amp;save=Save CVs</code></p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload